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

r/lb_target_group: Don't allow invalid configurations #15612

Closed
YakDriver opened this issue Oct 12, 2020 · 3 comments · Fixed by #22996
Closed

r/lb_target_group: Don't allow invalid configurations #15612

YakDriver opened this issue Oct 12, 2020 · 3 comments · Fixed by #22996
Assignees
Labels
breaking-change Introduces a breaking change in current functionality; usually deferred to the next major release. enhancement Requests to existing resources that expand the functionality or scope. partition/aws-us-gov Pertains to the aws-us-gov partition. service/elbv2 Issues and PRs that pertain to the elbv2 service.
Milestone

Comments

@YakDriver
Copy link
Member

YakDriver commented Oct 12, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Invalid aws_lb_target_group configurations were allowed in AWS provider 3.9 and before. In order to allow invalid configurations, the resource had error-avoiding logic in CustomizeDiff, Read, and Update. This logic was removed with 3.10 which broke the invalid configurations. The logic was added back (#15613) to avoid breaking invalid configurations. This logic should be removed.

The aws_lb_target_group can be fixed (not allowing invalid configurations) by following these steps (basically just undoing #15613):

  1. Remove the DiffSuppressFunc from stickiness.type
  2. in resourceAwsLbTargetGroupUpdate(), in if d.HasChange("stickiness"), remove the if statement if !stickiness["enabled"].(bool) && stickiness["type"].(string) == "lb_cookie".... DO NOT remove the else body: remove the if statement, the if body, and the else statement, and associated braces.
  3. In flattenAwsLbTargetGroupStickiness(), remove the if !stickinessMap["enabled"].(bool) && stickinessMap["type"].(string) statement, the if body, and the else word. Leave if err := d.Set("stickiness"...

New or Affected Resource(s)

  • aws_lb_target_group

Potential Terraform Configuration

This invalid configuration should result in an error even though the stickiness is disabled (consistent with the AWS API). This is invalid because the TCP protocol is not compatible with stickiness type of lb_cookie.

Invalid Config, Should Cause Error

resource "aws_lb_target_group" "test" {
   protocol = "TCP" # or "UDP", "TCP_UDP", or "TLS"
   # other config

   stickiness {
     type    = "lb_cookie"
     enabled = false
   }
 }

Invalid Config, Does Cause Error

resource "aws_lb_target_group" "test" {
   protocol = "HTTP" # or "HTTPS"
   # other config

   stickiness {
     type    = "source_ip"
     enabled = false
   }
 }

Valid Config, Should Not Cause Error

resource "aws_lb_target_group" "test" {
   protocol = "TCP" # or "UDP", "TCP_UDP", or "TLS"
   # other config

   stickiness {
     type    = "source_ip"
     enabled = false
   }
 }

Valid Config, Should Not Cause Error

resource "aws_lb_target_group" "test" {
   protocol = "HTTP" # or "HTTPS"
   # other config

   stickiness {
     type    = "lb_cookie"
     enabled = false
   }
 }

References

@YakDriver YakDriver added enhancement Requests to existing resources that expand the functionality or scope. breaking-change Introduces a breaking change in current functionality; usually deferred to the next major release. service/elbv2 Issues and PRs that pertain to the elbv2 service. partition/aws-us-gov Pertains to the aws-us-gov partition. labels Oct 12, 2020
@YakDriver
Copy link
Member Author

Potentially helpful notes for this resource that I'll leave here:

ALB = HTTP, HTTPS
deregistration_delay.timeout_seconds
stickiness.enabled
stickiness.type = lb_cookie
load_balancing.algorithm.type
slow_start.duration_seconds
stickiness.lb_cookie.duration_seconds

NLB = TCP, UDP, TCP_UDP
deregistration_delay.timeout_seconds
stickiness.enabled
stickiness.type = source_ip
proxy_protocol_v2.enabled

NLB = TLS
deregistration_delay.timeout_seconds
stickiness.enabled = false
stickiness.type = source_ip
proxy_protocol_v2.enabled

@github-actions
Copy link

This functionality has been released in v4.0.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this issue 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 similar to this, 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 May 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking-change Introduces a breaking change in current functionality; usually deferred to the next major release. enhancement Requests to existing resources that expand the functionality or scope. partition/aws-us-gov Pertains to the aws-us-gov partition. service/elbv2 Issues and PRs that pertain to the elbv2 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant