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

resource/aws_lb: Fix ELBv2 attributes on create #3854

Merged
merged 3 commits into from
Mar 27, 2018
Merged

resource/aws_lb: Fix ELBv2 attributes on create #3854

merged 3 commits into from
Mar 27, 2018

Conversation

appilon
Copy link
Contributor

@appilon appilon commented Mar 21, 2018

Fix #3848

Load balancer attributes can only be added after creation with a Modify sdk call. Our Update function does not appear to detect the initial configuration with HasChange, using IsNewResource() appears to ensure on create the attributes are configured.

Specific to HTTP2 our internal state would have been wrong as the attribute keystring was incorrect (used our variable name and not amazon's strange dot notation). Also I noticed the acceptance tests were only checking internal state, as a more explicit check we now read the alb attributes and check the returned value.

My first initial implementation of the acceptance check is very inefficient for aggregate tests that want to validate multiple attributes we are wasting time fetching and iterating over and over. If feedback from others supports it I contemplated an acceptance tests that accepts a map or list of expected values and can check all of them in one pass.

Tests:

=== RUN   TestAccAWSLB_networkLoadbalancer_updateCrossZone
--- PASS: TestAccAWSLB_networkLoadbalancer_updateCrossZone (403.58s)
=== RUN   TestAccAWSLB_applicationLoadBalancer_updateHttp2
--- PASS: TestAccAWSLB_applicationLoadBalancer_updateHttp2 (400.61s)
=== RUN   TestAccAWSLB_applicationLoadBalancer_updateDeletionProtection
--- PASS: TestAccAWSLB_applicationLoadBalancer_updateDeletionProtection (365.67s)
=== RUN   TestAccAWSLB_accesslogs
--- PASS: TestAccAWSLB_accesslogs (392.42s)

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 21, 2018
@appilon appilon changed the title Fix ELBv2 attributes on create resource/aws_lb: Fix ELBv2 attributes on create Mar 21, 2018
@mpilar
Copy link
Contributor

mpilar commented Mar 21, 2018

Nice catch, looks very good to me.

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 22, 2018
@appilon appilon requested a review from a team March 22, 2018 18:33
@ghost ghost added size/M Managed by automation to categorize the size of a PR. labels Mar 22, 2018
Copy link
Member

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

a couple of minor comments, otherwise LGTM 👍

@@ -707,7 +707,7 @@ func flattenAwsLbResource(d *schema.ResourceData, meta interface{}, lb *elbv2.Lo
protectionEnabled := (*attr.Value) == "true"
log.Printf("[DEBUG] Setting LB Deletion Protection Enabled: %t", protectionEnabled)
d.Set("enable_deletion_protection", protectionEnabled)
case "enable_http2":
Copy link
Member

Choose a reason for hiding this comment

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

is the old key still valid, or is this a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bug 🐛

if *attr.Value == value {
return nil
} else {
return fmt.Errorf(`LB attribute %s expected: "%s" actual: "%s"`, key, value, *attr.Value)
Copy link
Member

Choose a reason for hiding this comment

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

minor you can use %q rather than %s to do the same thing as "%s" :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TIL!

@bflad bflad added bug Addresses a defect in current functionality. service/elbv2 Issues and PRs that pertain to the elbv2 service. labels Mar 27, 2018
add acceptance checks on attribute tests
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Mar 27, 2018
@appilon appilon merged commit 96288bc into hashicorp:master Mar 27, 2018
@bflad bflad added this to the v1.13.0 milestone Mar 29, 2018
@bflad
Copy link
Contributor

bflad commented Mar 29, 2018

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

@ghost
Copy link

ghost commented Apr 7, 2020

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!

@ghost ghost locked and limited conversation to collaborators Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/elbv2 Issues and PRs that pertain to the elbv2 service. size/M Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ELBv2 attributes do not configure properly on create
4 participants