-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
resource/aws_lb: enable_http2 flag for LBs and small refactor #3609
Conversation
- refactored to use a switch statement a la hashicorp#3578 - added enable_http2 as a flag with tests - made the boolean flag tests have 3 steps: on, off, on. to test creation, removal and enabling of a running LB - increased timeout and delay for aws_internet_gateway detachment refresh - increased wait time to wait for network interfaces to be destroyed after deleting an NLB (this, combined with the above, caused the EIP hanging resource I saw yesterday) - made all test fixtures use lb_test as the name for the aws_lb (to prevent the typo issue I had)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again @mpilar! I left some initial review comments. Can you please take a look and let me know if you have any questions? 👍
aws/resource_aws_lb_test.go
Outdated
@@ -1026,7 +1139,7 @@ resource "aws_lb" "test" { | |||
} | |||
|
|||
resource "aws_eip" "lb" { | |||
count = "${length(data.aws_availability_zones.available.names)}" | |||
count = "${length(data.aws_availability_zones.available.names)>2?2:length(data.aws_availability_zones.available.names)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any regions with only 1 AZ? Seems like this should just be count = 2
aws/resource_aws_lb_test.go
Outdated
@@ -874,6 +919,75 @@ resource "aws_security_group" "alb_test" { | |||
}`, lbName) | |||
} | |||
|
|||
func testAccAWSLBConfig_basicWithHttp2Toggle(lbName string, http2 bool) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpick: generally we would just name this testAccAWSLBConfig_enableHttp2
aws/resource_aws_lb.go
Outdated
Value: aws.String(fmt.Sprintf("%t", d.Get("enable_cross_zone_load_balancing").(bool))), | ||
}) | ||
} | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would we hit this scenario? This currently will never hit. Also, I'm not sure the benefit of postulating if/when there may be new load balancer types and having any sort of implicit support of them. We should force a provider update with acceptance testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a mistake in my PR (which was coded offline on plane), I forgot Go's switch doesn't fallthrough by default
aws/resource_aws_lb.go
Outdated
}) | ||
} | ||
default: | ||
if d.HasChange("enable_deletion_protection") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the note above about default:
, shouldn't this be a part of both application and network load balancers? It can be moved outside the switch statement. Also, this likely would've been caught in an acceptance test, which looks like it should be added to enable and then disable this (so it can actually be destroyed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add an acceptance test. (and fix the switch statement)
aws/resource_aws_internet_gateway.go
Outdated
Timeout: 15 * time.Minute, | ||
Delay: 20 * time.Second, | ||
NotFoundChecks: 30, | ||
ContinuousTargetOccurence: 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably PR and acceptance test this separately 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove it for now.
=== RUN TestAccAWSLB_applicationLoadBalancer_updateDeletionProtection --- PASS: TestAccAWSLB_applicationLoadBalancer_updateDeletionProtection (373.19s) PASS ok github.com/terraform-providers/terraform-provider-aws/aws 373.854s
After last commit. |
@appilon I would love a review from you as well. |
Looks good to me! (I'm still new to the project and can only really comment on general code/go things) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, excellent job! 🚀
16 tests passed (all tests)
=== RUN TestAccAWSLB_networkLoadbalancerBasic
--- PASS: TestAccAWSLB_networkLoadbalancerBasic (218.94s)
=== RUN TestAccAWSLB_noSecurityGroup
--- PASS: TestAccAWSLB_noSecurityGroup (230.41s)
=== RUN TestAccAWSLB_namePrefix
--- PASS: TestAccAWSLB_namePrefix (253.01s)
=== RUN TestAccAWSLB_networkLoadbalancer_subnet_change
--- PASS: TestAccAWSLB_networkLoadbalancer_subnet_change (332.01s)
=== RUN TestAccAWSLB_networkLoadbalancerEIP
--- PASS: TestAccAWSLB_networkLoadbalancerEIP (345.82s)
=== RUN TestAccAWSLB_basic
--- PASS: TestAccAWSLB_basic (349.05s)
=== RUN TestAccAWSLB_updatedIpAddressType
--- PASS: TestAccAWSLB_updatedIpAddressType (379.98s)
=== RUN TestAccAWSLB_accesslogs
--- PASS: TestAccAWSLB_accesslogs (381.61s)
=== RUN TestAccAWSLB_generatesNameForZeroValue
--- PASS: TestAccAWSLB_generatesNameForZeroValue (404.03s)
=== RUN TestAccAWSLB_generatedName
--- PASS: TestAccAWSLB_generatedName (404.05s)
=== RUN TestAccAWSLB_applicationLoadBalancer_updateDeletionProtection
--- PASS: TestAccAWSLB_applicationLoadBalancer_updateDeletionProtection (412.53s)
=== RUN TestAccAWSLB_updatedSubnets
--- PASS: TestAccAWSLB_updatedSubnets (464.73s)
=== RUN TestAccAWSLB_applicationLoadBalancer_updateHttp2
--- PASS: TestAccAWSLB_applicationLoadBalancer_updateHttp2 (469.82s)
=== RUN TestAccAWSLB_tags
--- PASS: TestAccAWSLB_tags (471.29s)
=== RUN TestAccAWSLB_networkLoadbalancer_updateCrossZone
--- PASS: TestAccAWSLB_networkLoadbalancer_updateCrossZone (493.27s)
=== RUN TestAccAWSLB_updatedSecurityGroups
--- PASS: TestAccAWSLB_updatedSecurityGroups (581.41s)
}) | ||
} | ||
|
||
func TestAccAWSLB_applicationLoadBalancer_updateDeletionProtection(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!!!
This has been released in version 1.11.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Closes: #3511
Note about the last two: The fail in acceptance tests seemed to happen more with cross-zone enabled, it's not an issue of the acceptance test but the speed at which AWS can successfully destroy the resources related to the NLB, seems that cross-zone makes that destruction slower somewhat.
Test results: