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: Support weight in forward action #224

Conversation

alexbricepalo
Copy link
Contributor

@alexbricepalo alexbricepalo commented Oct 16, 2021

Description

Added a 'weighted-forward' dynamic action block to use with the https_listener_rules for multiple weighted target_group

Motivation and Context

This adds a dynamic action block for a "weighted-forward" action_rule.type for the https_listener_rules . It allows us to create a listener rule like:

{
  https_listener_index = 0
  priority             = 30

  actions = [
    {
      type = "weighted-forward"
      target_groups = [
        {
          target_group_index = 1
          weight             = 1
        },
        {
          target_group_index = 0
          weight             = 0
        }
      ]
    }
  ]

  conditions = [{}]
}

Fixes #211

Breaking Changes

No breaking changes

How Has This Been Tested?

  • [√] I have tested and validated these changes using one or more of the provided examples/* projects

I created the resources and visually verified the correct rules made it onto the load balancer.

+ forward {
  + stickiness {
    + duration = 0
    + enabled  = false
  }
  
  + target_group {
    + arn    = "arn:aws:elasticloadbalancing:us-east-1:../f0eaf247061478b5"
    + weight = 1
  }
  + target_group {
    + arn    = "arn:aws:elasticloadbalancing:us-east-1:../9bb7dfca9e8b8565"
    + weight = 2
  }
}

Copy link
Member

@antonbabenko antonbabenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but there is a bug in the provider (hashicorp/terraform-provider-aws#15144) and we need to come up with a workaround for it.

main.tf Outdated
content {
type = "forward"
forward {
dynamic target_group {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dynamic target_group {
dynamic "target_group" {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could you make sure that the example works when values in weight change?

Currently, terraform apply fails after changing it with this error:

│ Error: Error modifying LB Listener Rule: ValidationError: Target group stickiness duration must be between 1 and 604800 seconds

Here is a related bug - hashicorp/terraform-provider-aws#15144

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @antonbabenko. I updated my PR and added the stickiness block.

@antonbabenko antonbabenko changed the title feat: Support weight in forward action #211 feat: Support weight in forward action Nov 19, 2021
@antonbabenko antonbabenko merged commit 6b5f0d4 into terraform-aws-modules:master Nov 19, 2021
@antonbabenko
Copy link
Member

Thanks, @alexbricepalo !

v6.6.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.

Feature request: Support weight in forward action
2 participants