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

Bugfix: Allow aws_elb subnets update that would remove all current subnets #31976

Merged
merged 23 commits into from
Jun 15, 2023

Conversation

brittandeyoung
Copy link
Collaborator

@brittandeyoung brittandeyoung commented Jun 14, 2023

Description

This PR enables the aws_elb resource update flow to allow for removing all current subnets and setting new subnets. This is accomplished by forcing a new resource when this condition occurs. As the api only supports remove and add of subnets, not a single update (like the new elbv2 api), this is the best way to accomplish this. Currently the apply will simply fail stating that you cannot remove all subnets associated with the load balancer and manually deleting the resource is required in order to perform the update. This update will handle all of that in the resource.

A test step has been added to validate the resolved functionality and test outputs before the issue was resolved show the error. After the fix, the tests are now passing.

Relations

Closes #727.
Closes #8180.

References

Output from Acceptance Testing

Test Added To replicate bug

$  make testacc TESTARGS='-run=TestAccELBLoadBalancer_Swap_subnets' PKG=elb
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/elb/... -v -count 1 -parallel 20  -run=TestAccELBLoadBalancer_Swap_subnets -timeout 180m
=== RUN   TestAccELBLoadBalancer_Swap_subnets
=== PAUSE TestAccELBLoadBalancer_Swap_subnets
=== CONT  TestAccELBLoadBalancer_Swap_subnets
    load_balancer_test.go:383: Step 3/3 error: Error running apply: exit status 1
        
        Error: Failure removing ELB subnets: InvalidConfigurationRequest: Requested configuration change for LoadBalancer "tf-lb-20230613210207413600000001" is invalid because you attempted to detach all the subnets for this LoadBalancer and a LoadBalancer cannot be attached to zero subnets in VPC.
                status code: 409, request id: 675889ea-9c10-46b9-96f6-ad5a79baa2b8
        
          with aws_elb.test,
          on terraform_plugin_test.tf line 60, in resource "aws_elb" "test":
          60: resource "aws_elb" "test" {
        
--- FAIL: TestAccELBLoadBalancer_Swap_subnets (87.71s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/elb        92.669s
FAIL
make: *** [testacc] Error 1
...

Test output after bugfix

make testacc TESTARGS='-run=TestAccELBLoadBalancer_Swap_subnets' PKG=elb
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/elb/... -v -count 1 -parallel 20  -run=TestAccELBLoadBalancer_Swap_subnets -timeout 180m
=== RUN   TestAccELBLoadBalancer_Swap_subnets
=== PAUSE TestAccELBLoadBalancer_Swap_subnets
=== CONT  TestAccELBLoadBalancer_Swap_subnets
--- PASS: TestAccELBLoadBalancer_Swap_subnets (82.24s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/elb        85.604s

@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/M Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/elb Issues and PRs that pertain to the elb service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. needs-triage Waiting for first response or review from a maintainer. labels Jun 14, 2023
@brittandeyoung brittandeyoung added the bug Addresses a defect in current functionality. label Jun 14, 2023
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Jun 14, 2023
@github-actions github-actions bot added size/XL Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Jun 15, 2023
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccELBLoadBalancer_' PKG=elb ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/elb/... -v -count 1 -parallel 3  -run=TestAccELBLoadBalancer_ -timeout 180m
=== RUN   TestAccELBLoadBalancer_basic
=== PAUSE TestAccELBLoadBalancer_basic
=== RUN   TestAccELBLoadBalancer_disappears
=== PAUSE TestAccELBLoadBalancer_disappears
=== RUN   TestAccELBLoadBalancer_namePrefix
=== PAUSE TestAccELBLoadBalancer_namePrefix
=== RUN   TestAccELBLoadBalancer_nameGenerated
=== PAUSE TestAccELBLoadBalancer_nameGenerated
=== RUN   TestAccELBLoadBalancer_tags
=== PAUSE TestAccELBLoadBalancer_tags
=== RUN   TestAccELBLoadBalancer_fullCharacterRange
=== PAUSE TestAccELBLoadBalancer_fullCharacterRange
=== RUN   TestAccELBLoadBalancer_AccessLogs_enabled
=== PAUSE TestAccELBLoadBalancer_AccessLogs_enabled
=== RUN   TestAccELBLoadBalancer_AccessLogs_disabled
=== PAUSE TestAccELBLoadBalancer_AccessLogs_disabled
=== RUN   TestAccELBLoadBalancer_generatesNameForZeroValue
=== PAUSE TestAccELBLoadBalancer_generatesNameForZeroValue
=== RUN   TestAccELBLoadBalancer_availabilityZones
=== PAUSE TestAccELBLoadBalancer_availabilityZones
=== RUN   TestAccELBLoadBalancer_ListenerSSLCertificateID_iamServerCertificate
=== PAUSE TestAccELBLoadBalancer_ListenerSSLCertificateID_iamServerCertificate
=== RUN   TestAccELBLoadBalancer_Swap_subnets
=== PAUSE TestAccELBLoadBalancer_Swap_subnets
=== RUN   TestAccELBLoadBalancer_instanceAttaching
=== PAUSE TestAccELBLoadBalancer_instanceAttaching
=== RUN   TestAccELBLoadBalancer_listener
=== PAUSE TestAccELBLoadBalancer_listener
=== RUN   TestAccELBLoadBalancer_healthCheck
=== PAUSE TestAccELBLoadBalancer_healthCheck
=== RUN   TestAccELBLoadBalancer_timeout
=== PAUSE TestAccELBLoadBalancer_timeout
=== RUN   TestAccELBLoadBalancer_connectionDraining
=== PAUSE TestAccELBLoadBalancer_connectionDraining
=== RUN   TestAccELBLoadBalancer_securityGroups
=== PAUSE TestAccELBLoadBalancer_securityGroups
=== RUN   TestAccELBLoadBalancer_desyncMitigationMode
=== PAUSE TestAccELBLoadBalancer_desyncMitigationMode
=== RUN   TestAccELBLoadBalancer_desyncMitigationMode_update
=== PAUSE TestAccELBLoadBalancer_desyncMitigationMode_update
=== CONT  TestAccELBLoadBalancer_basic
=== CONT  TestAccELBLoadBalancer_ListenerSSLCertificateID_iamServerCertificate
=== CONT  TestAccELBLoadBalancer_fullCharacterRange
=== CONT  TestAccELBLoadBalancer_nameGenerated
--- PASS: TestAccELBLoadBalancer_fullCharacterRange (34.72s)
--- PASS: TestAccELBLoadBalancer_basic (39.70s)
=== CONT  TestAccELBLoadBalancer_tags
--- PASS: TestAccELBLoadBalancer_ListenerSSLCertificateID_iamServerCertificate (51.56s)
=== CONT  TestAccELBLoadBalancer_namePrefix
--- PASS: TestAccELBLoadBalancer_nameGenerated (33.58s)
=== CONT  TestAccELBLoadBalancer_timeout
--- PASS: TestAccELBLoadBalancer_namePrefix (35.37s)
=== CONT  TestAccELBLoadBalancer_desyncMitigationMode_update
--- PASS: TestAccELBLoadBalancer_timeout (57.21s)
=== CONT  TestAccELBLoadBalancer_desyncMitigationMode
--- PASS: TestAccELBLoadBalancer_tags (89.02s)
=== CONT  TestAccELBLoadBalancer_securityGroups
--- PASS: TestAccELBLoadBalancer_desyncMitigationMode (37.25s)
=== CONT  TestAccELBLoadBalancer_connectionDraining
--- PASS: TestAccELBLoadBalancer_desyncMitigationMode_update (90.59s)
=== CONT  TestAccELBLoadBalancer_generatesNameForZeroValue
--- PASS: TestAccELBLoadBalancer_securityGroups (62.26s)
=== CONT  TestAccELBLoadBalancer_availabilityZones
--- PASS: TestAccELBLoadBalancer_generatesNameForZeroValue (32.49s)
=== CONT  TestAccELBLoadBalancer_AccessLogs_disabled
--- PASS: TestAccELBLoadBalancer_connectionDraining (79.81s)
=== CONT  TestAccELBLoadBalancer_AccessLogs_enabled
--- PASS: TestAccELBLoadBalancer_availabilityZones (55.97s)
=== CONT  TestAccELBLoadBalancer_disappears
--- PASS: TestAccELBLoadBalancer_disappears (26.07s)
=== CONT  TestAccELBLoadBalancer_listener
--- PASS: TestAccELBLoadBalancer_AccessLogs_disabled (81.01s)
=== CONT  TestAccELBLoadBalancer_healthCheck
--- PASS: TestAccELBLoadBalancer_AccessLogs_enabled (81.08s)
=== CONT  TestAccELBLoadBalancer_instanceAttaching
--- PASS: TestAccELBLoadBalancer_healthCheck (53.73s)
=== CONT  TestAccELBLoadBalancer_Swap_subnets
--- PASS: TestAccELBLoadBalancer_Swap_subnets (90.01s)
--- PASS: TestAccELBLoadBalancer_listener (136.53s)
--- PASS: TestAccELBLoadBalancer_instanceAttaching (121.77s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/elb	451.558s

@ewbankkit
Copy link
Contributor

@brittandeyoung Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit 507faa6 into hashicorp:main Jun 15, 2023
@github-actions github-actions bot added this to the v5.4.0 milestone Jun 15, 2023
@github-actions
Copy link

This functionality has been released in v5.4.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 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 Jul 16, 2023
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. documentation Introduces or discusses updates to documentation. service/elb Issues and PRs that pertain to the elb service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't change subnet on ELB
4 participants