Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added listener rules support #155

Merged

Conversation

dmattia
Copy link
Contributor

@dmattia dmattia commented Apr 24, 2020

Description

Added listener rules support.

This PR adds support for creating aws_lb_listener_rule resources, with all currently supported actions and conditions from the terraform provider supported. For now, I only added support to https listeners, but adding http listener support later would be trivial.

Docs wise, I updated the REAMDE to include an example of using the listener_rule var, and also updated the example to have near-complete usage.

Motivation and Context

This repo recently added support for updating the default rule for a listener, which was awesome. This PR goes one step further, for adding rules with conditions, such as only protecting certain paths with authentication.

Fixes: #154

Breaking Changes

There are no breaking changes. Plans will be empty on upgrades to use this branch's code if users do not make any changes.

How Has This Been Tested?

I have tested some of the actions/conditions in the dev environment in my companies codebase. I also updated the complete alb example to use almost every actions/condition type and ensured that terraform validate came up clean.

@antonbabenko
Copy link
Member

Hi @dmattia !

At first look, it looks very good to me, but I don't have a lot of time to review it and verify examples.

@rriveramdz could you please take a look at this? In particular, I wonder if there are any differences in code between this PR and your recent PR where you added actions.

Thanks guys!

@antonbabenko antonbabenko changed the title Added listener rules support feat: Added listener rules support Apr 24, 2020
@rriveramdz
Copy link
Contributor

Hi @dmattia.

This looks really great. I guess the only thing I think should be added is to add in README and examples that there's a maximum of two actions per load balancer rule, so that users have this clear.

@dmattia dmattia force-pushed the dmattia/listener_rules branch from 0c71c70 to a71fb49 Compare April 27, 2020 16:00
@dmattia
Copy link
Contributor Author

dmattia commented Apr 27, 2020

Awesome, thanks for the quick reviews both of you!

I updated the README to include a warning about how to use the actions properly on load balancer rules.

@dmattia dmattia requested a review from antonbabenko April 28, 2020 20:56
@dmattia
Copy link
Contributor Author

dmattia commented Jun 2, 2020

Just updated the branch. Please let me know if there's anything else I can do

@limratechnologies
Copy link

limratechnologies commented Jun 8, 2020

@dmattia Thanks for this, looks awesome.

Tried running the code, I'm getting the below error, Am I doing something wrong?

Error: Invalid index

  on ../../../../terraform-aws-alb-module/alb.tf line 388, in resource "aws_lb_listener_rule" "https_listener_rule":
 388:         http_header_name = condition.value["http_headers"]["http_header_name"]
    |----------------
    | condition.value["http_headers"] is tuple with 1 element

The given key does not identify an element in this collection value: a number
is required.


Error: Invalid index

  on ../../../../terraform-aws-alb-module/alb.tf line 389, in resource "aws_lb_listener_rule" "https_listener_rule":
 389:         values           = condition.value["http_headers"]["values"]
    |----------------
    | condition.value["http_headers"] is tuple with 1 element

The given key does not identify an element in this collection value: a number
is required.

@dmattia
Copy link
Contributor Author

dmattia commented Jun 8, 2020

@limratechnologies what does your condition look like? In particular, your http_headers?

@limratechnologies
Copy link

@dmattia I have used the format mentioned in the example.

@dmattia dmattia force-pushed the dmattia/listener_rules branch from 635fbcf to c6a61fc Compare September 4, 2020 03:17
@dmattia
Copy link
Contributor Author

dmattia commented Sep 4, 2020

Sure, I just updated a fix to the issue @limratechnologies had, and now the complete example works.

It's ready for review now

@antonbabenko antonbabenko merged commit 03cad59 into terraform-aws-modules:master Sep 11, 2020
@antonbabenko
Copy link
Member

Thanks, @dmattia and @rriveramdz !

v5.9.0 has been just released.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow listener rules with conditions
4 participants