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

Ensure Sequential Update of Elastic Beanstalk Tags and Environment Properties #36074

Conversation

alexknez
Copy link
Contributor

@alexknez alexknez commented Mar 4, 2024

Description

This PR addresses an issue encountered in Elastic Beanstalk environments. Previously, when tags were updated concurrently with environment properties, the provider would fail, presenting the following error message:

Error: updating Elastic Beanstalk Environment (e-envid): InvalidParameterValue: Environment named env-name is in an invalid state for this operation. Must be Ready.
status code: 400, request id: request-id 

This error arose due to the sequence of API calls involved in the process:

  • UpdateTagsForResource
  • UpdateEvironment

The UpdateTagsForResource call preceded UpdateEnvironment, but it required additional time for changes to propagate throughout the Beanstalk environment.

Changes Made

To resolve this issue, this PR introduces a wait condition following the UpdateTagsForResource call to ensure its completion before triggering UpdateEnvironment. By adding this wait condition, we ensure that the environment is in the correct state to receive subsequent updates, thereby preventing the aforementioned error.

Relations

Closes #32284
Closes #31575

References

Output from Acceptance Testing

% make testacc TESTARGS="-run=TestAccElasticBeanstalk" PKG=elasticbeanstalk                          
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/elasticbeanstalk/... -v -count 1 -parallel 20  -run=TestAccElasticBeanstalk -timeout 360m
=== RUN   TestAccElasticBeanstalkApplicationDataSource_basic
=== PAUSE TestAccElasticBeanstalkApplicationDataSource_basic
=== RUN   TestAccElasticBeanstalkApplication_basic
=== PAUSE TestAccElasticBeanstalkApplication_basic
=== RUN   TestAccElasticBeanstalkApplication_disappears
=== PAUSE TestAccElasticBeanstalkApplication_disappears
=== RUN   TestAccElasticBeanstalkApplication_tags
=== PAUSE TestAccElasticBeanstalkApplication_tags
=== RUN   TestAccElasticBeanstalkApplication_description
=== PAUSE TestAccElasticBeanstalkApplication_description
=== RUN   TestAccElasticBeanstalkApplication_appVersionLifecycle
=== PAUSE TestAccElasticBeanstalkApplication_appVersionLifecycle
=== RUN   TestAccElasticBeanstalkApplicationVersion_BeanstalkApp_basic
=== PAUSE TestAccElasticBeanstalkApplicationVersion_BeanstalkApp_basic
=== RUN   TestAccElasticBeanstalkApplicationVersion_BeanstalkApp_duplicateLabels
=== PAUSE TestAccElasticBeanstalkApplicationVersion_BeanstalkApp_duplicateLabels
=== RUN   TestAccElasticBeanstalkApplicationVersion_BeanstalkApp_tags
=== PAUSE TestAccElasticBeanstalkApplicationVersion_BeanstalkApp_tags
=== RUN   TestAccElasticBeanstalkConfigurationTemplate_basic
=== PAUSE TestAccElasticBeanstalkConfigurationTemplate_basic
=== RUN   TestAccElasticBeanstalkConfigurationTemplate_disappears
=== PAUSE TestAccElasticBeanstalkConfigurationTemplate_disappears
=== RUN   TestAccElasticBeanstalkConfigurationTemplate_Disappears_application
=== PAUSE TestAccElasticBeanstalkConfigurationTemplate_Disappears_application
=== RUN   TestAccElasticBeanstalkConfigurationTemplate_vpc
=== PAUSE TestAccElasticBeanstalkConfigurationTemplate_vpc
=== RUN   TestAccElasticBeanstalkConfigurationTemplate_settings
=== PAUSE TestAccElasticBeanstalkConfigurationTemplate_settings
=== RUN   TestAccElasticBeanstalkEnvironment_basic
=== PAUSE TestAccElasticBeanstalkEnvironment_basic
=== RUN   TestAccElasticBeanstalkEnvironment_disappears
=== PAUSE TestAccElasticBeanstalkEnvironment_disappears
=== RUN   TestAccElasticBeanstalkEnvironment_tier
=== PAUSE TestAccElasticBeanstalkEnvironment_tier
=== RUN   TestAccElasticBeanstalkEnvironment_cnamePrefix
=== PAUSE TestAccElasticBeanstalkEnvironment_cnamePrefix
=== RUN   TestAccElasticBeanstalkEnvironment_beanstalkEnv
=== PAUSE TestAccElasticBeanstalkEnvironment_beanstalkEnv
=== RUN   TestAccElasticBeanstalkEnvironment_resource
=== PAUSE TestAccElasticBeanstalkEnvironment_resource
=== RUN   TestAccElasticBeanstalkEnvironment_tags
=== PAUSE TestAccElasticBeanstalkEnvironment_tags
=== RUN   TestAccElasticBeanstalkEnvironment_changeStack
=== PAUSE TestAccElasticBeanstalkEnvironment_changeStack
=== RUN   TestAccElasticBeanstalkEnvironment_update
=== PAUSE TestAccElasticBeanstalkEnvironment_update
=== RUN   TestAccElasticBeanstalkEnvironment_label
=== PAUSE TestAccElasticBeanstalkEnvironment_label
=== RUN   TestAccElasticBeanstalkEnvironment_settingWithJSONValue
=== PAUSE TestAccElasticBeanstalkEnvironment_settingWithJSONValue
=== RUN   TestAccElasticBeanstalkEnvironment_platformARN
=== PAUSE TestAccElasticBeanstalkEnvironment_platformARN
=== RUN   TestAccElasticBeanstalkHostedZoneDataSource_basic
=== PAUSE TestAccElasticBeanstalkHostedZoneDataSource_basic
=== RUN   TestAccElasticBeanstalkHostedZoneDataSource_region
=== PAUSE TestAccElasticBeanstalkHostedZoneDataSource_region
=== RUN   TestAccElasticBeanstalkSolutionStackDataSource_basic
=== PAUSE TestAccElasticBeanstalkSolutionStackDataSource_basic
=== CONT  TestAccElasticBeanstalkApplicationDataSource_basic
=== CONT  TestAccElasticBeanstalkEnvironment_disappears
=== CONT  TestAccElasticBeanstalkApplicationVersion_BeanstalkApp_tags
=== CONT  TestAccElasticBeanstalkApplication_description
=== CONT  TestAccElasticBeanstalkConfigurationTemplate_Disappears_application
=== CONT  TestAccElasticBeanstalkConfigurationTemplate_basic
=== CONT  TestAccElasticBeanstalkConfigurationTemplate_vpc
=== CONT  TestAccElasticBeanstalkEnvironment_basic
=== CONT  TestAccElasticBeanstalkConfigurationTemplate_settings
=== CONT  TestAccElasticBeanstalkApplicationVersion_BeanstalkApp_basic
=== CONT  TestAccElasticBeanstalkApplicationVersion_BeanstalkApp_duplicateLabels
=== CONT  TestAccElasticBeanstalkApplication_appVersionLifecycle
=== CONT  TestAccElasticBeanstalkEnvironment_update
=== CONT  TestAccElasticBeanstalkSolutionStackDataSource_basic
=== CONT  TestAccElasticBeanstalkHostedZoneDataSource_region
=== CONT  TestAccElasticBeanstalkHostedZoneDataSource_basic
=== CONT  TestAccElasticBeanstalkEnvironment_platformARN
=== CONT  TestAccElasticBeanstalkEnvironment_settingWithJSONValue
=== CONT  TestAccElasticBeanstalkEnvironment_label
=== CONT  TestAccElasticBeanstalkConfigurationTemplate_disappears
--- PASS: TestAccElasticBeanstalkSolutionStackDataSource_basic (28.48s)
=== CONT  TestAccElasticBeanstalkEnvironment_resource
--- PASS: TestAccElasticBeanstalkHostedZoneDataSource_basic (28.68s)
=== CONT  TestAccElasticBeanstalkEnvironment_changeStack
--- PASS: TestAccElasticBeanstalkApplicationVersion_BeanstalkApp_basic (37.47s)
=== CONT  TestAccElasticBeanstalkEnvironment_tags
--- PASS: TestAccElasticBeanstalkConfigurationTemplate_Disappears_application (40.73s)
=== CONT  TestAccElasticBeanstalkEnvironment_cnamePrefix
--- PASS: TestAccElasticBeanstalkApplicationVersion_BeanstalkApp_duplicateLabels (41.09s)
=== CONT  TestAccElasticBeanstalkEnvironment_beanstalkEnv
--- PASS: TestAccElasticBeanstalkConfigurationTemplate_settings (41.17s)
=== CONT  TestAccElasticBeanstalkApplication_disappears
=== CONT  TestAccElasticBeanstalkApplication_tags
--- PASS: TestAccElasticBeanstalkApplicationDataSource_basic (41.28s)
--- PASS: TestAccElasticBeanstalkConfigurationTemplate_basic (41.61s)
=== CONT  TestAccElasticBeanstalkEnvironment_tier
--- PASS: TestAccElasticBeanstalkConfigurationTemplate_vpc (42.77s)
=== CONT  TestAccElasticBeanstalkApplication_basic
--- PASS: TestAccElasticBeanstalkConfigurationTemplate_disappears (42.95s)
--- PASS: TestAccElasticBeanstalkHostedZoneDataSource_region (44.97s)
--- PASS: TestAccElasticBeanstalkApplication_description (55.51s)
--- PASS: TestAccElasticBeanstalkApplication_disappears (17.14s)
--- PASS: TestAccElasticBeanstalkApplication_basic (18.64s)
--- PASS: TestAccElasticBeanstalkApplication_tags (31.77s)
--- PASS: TestAccElasticBeanstalkApplication_appVersionLifecycle (73.98s)
--- PASS: TestAccElasticBeanstalkApplicationVersion_BeanstalkApp_tags (75.47s)
--- PASS: TestAccElasticBeanstalkEnvironment_basic (329.32s)
--- PASS: TestAccElasticBeanstalkEnvironment_resource (317.92s)
--- PASS: TestAccElasticBeanstalkEnvironment_cnamePrefix (317.48s)
--- PASS: TestAccElasticBeanstalkEnvironment_settingWithJSONValue (360.47s)
--- PASS: TestAccElasticBeanstalkEnvironment_label (372.30s)
--- PASS: TestAccElasticBeanstalkEnvironment_platformARN (388.78s)
--- PASS: TestAccElasticBeanstalkEnvironment_beanstalkEnv (353.54s)
--- PASS: TestAccElasticBeanstalkEnvironment_changeStack (425.39s)
--- PASS: TestAccElasticBeanstalkEnvironment_update (487.56s)
--- PASS: TestAccElasticBeanstalkEnvironment_tags (454.35s)
--- PASS: TestAccElasticBeanstalkEnvironment_tier (470.05s)
--- PASS: TestAccElasticBeanstalkEnvironment_disappears (545.85s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/elasticbeanstalk   550.060s

Copy link

github-actions bot commented Mar 4, 2024

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 service/elasticbeanstalk Issues and PRs that pertain to the elasticbeanstalk service. size/XS Managed by automation to categorize the size of a PR. labels Mar 4, 2024
@terraform-aws-provider terraform-aws-provider bot added needs-triage Waiting for first response or review from a maintainer. partner Contribution from a partner. labels Mar 4, 2024
@alexknez alexknez force-pushed the b-fix-beanstalk-environment-update-tags-environment branch from fc5c39b to 4842e5c Compare March 4, 2024 18:45
@alexknez alexknez force-pushed the b-fix-beanstalk-environment-update-tags-environment branch from 4842e5c to 1be3663 Compare March 4, 2024 18:51
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 5, 2024
@ewbankkit ewbankkit self-assigned this Mar 5, 2024
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Mar 5, 2024
% make testacc TESTARGS='-run=TestAccElasticBeanstalkEnvironment_platformARN' PKG=elasticbeanstalk
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/elasticbeanstalk/... -v -count 1 -parallel 20  -run=TestAccElasticBeanstalkEnvironment_platformARN -timeout 360m
=== RUN   TestAccElasticBeanstalkEnvironment_platformARN
=== PAUSE TestAccElasticBeanstalkEnvironment_platformARN
=== CONT  TestAccElasticBeanstalkEnvironment_platformARN
--- PASS: TestAccElasticBeanstalkEnvironment_platformARN (521.22s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/elasticbeanstalk	528.417s
% make testacc TESTARGS='-run=TestAccElasticBeanstalkEnvironment_platformARN' PKG=elasticbeanstalk
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/elasticbeanstalk/... -v -count 1 -parallel 20  -run=TestAccElasticBeanstalkEnvironment_platformARN -timeout 360m
=== RUN   TestAccElasticBeanstalkEnvironment_platformARN
=== PAUSE TestAccElasticBeanstalkEnvironment_platformARN
=== CONT  TestAccElasticBeanstalkEnvironment_platformARN
    environment_test.go:455: Step 3/3 error: Error running apply: exit status 1

        Error: updating Elastic Beanstalk Environment (e-96qne4yupz): operation error Elastic Beanstalk: UpdateEnvironment, https response error StatusCode: 400, RequestID: 3dd120a1-00dc-4407-a4d8-87e42587c9fb, api error InvalidParameterValue: Environment named tf-acc-test-8006851858569271934 is in an invalid state for this operation. Must be Ready.

          with aws_elastic_beanstalk_environment.test,
          on terraform_plugin_test.tf line 149, in resource "aws_elastic_beanstalk_environment" "test":
         149: resource "aws_elastic_beanstalk_environment" "test" {

--- FAIL: TestAccElasticBeanstalkEnvironment_platformARN (414.31s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/elasticbeanstalk	421.358s
FAIL
make: *** [testacc] Error 1
% make testacc TESTARGS='-run=TestAccElasticBeanstalkEnvironment_platformARN' PKG=elasticbeanstalk
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/elasticbeanstalk/... -v -count 1 -parallel 20  -run=TestAccElasticBeanstalkEnvironment_platformARN -timeout 360m
=== RUN   TestAccElasticBeanstalkEnvironment_platformARN
=== PAUSE TestAccElasticBeanstalkEnvironment_platformARN
=== CONT  TestAccElasticBeanstalkEnvironment_platformARN
--- PASS: TestAccElasticBeanstalkEnvironment_platformARN (570.56s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/elasticbeanstalk	580.939s
@ewbankkit
Copy link
Contributor

Before

% make testacc TESTARGS='-run=TestAccElasticBeanstalkEnvironment_platformARN' PKG=elasticbeanstalk
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/elasticbeanstalk/... -v -count 1 -parallel 20  -run=TestAccElasticBeanstalkEnvironment_platformARN -timeout 360m
=== RUN   TestAccElasticBeanstalkEnvironment_platformARN
=== PAUSE TestAccElasticBeanstalkEnvironment_platformARN
=== CONT  TestAccElasticBeanstalkEnvironment_platformARN
    environment_test.go:455: Step 3/3 error: Error running apply: exit status 1
        
        Error: updating Elastic Beanstalk Environment (e-96qne4yupz): operation error Elastic Beanstalk: UpdateEnvironment, https response error StatusCode: 400, RequestID: 3dd120a1-00dc-4407-a4d8-87e42587c9fb, api error InvalidParameterValue: Environment named tf-acc-test-8006851858569271934 is in an invalid state for this operation. Must be Ready.
        
          with aws_elastic_beanstalk_environment.test,
          on terraform_plugin_test.tf line 149, in resource "aws_elastic_beanstalk_environment" "test":
         149: resource "aws_elastic_beanstalk_environment" "test" {
        
--- FAIL: TestAccElasticBeanstalkEnvironment_platformARN (414.31s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/elasticbeanstalk	421.358s
FAIL
make: *** [testacc] Error 1

After

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

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=TestAccElasticBeanstalkEnvironment_' PKG=elasticbeanstalk ACCTEST_PARALLELISM=3 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/elasticbeanstalk/... -v -count 1 -parallel 3  -run=TestAccElasticBeanstalkEnvironment_ -timeout 360m
=== RUN   TestAccElasticBeanstalkEnvironment_basic
=== PAUSE TestAccElasticBeanstalkEnvironment_basic
=== RUN   TestAccElasticBeanstalkEnvironment_disappears
=== PAUSE TestAccElasticBeanstalkEnvironment_disappears
=== RUN   TestAccElasticBeanstalkEnvironment_tier
=== PAUSE TestAccElasticBeanstalkEnvironment_tier
=== RUN   TestAccElasticBeanstalkEnvironment_cnamePrefix
=== PAUSE TestAccElasticBeanstalkEnvironment_cnamePrefix
=== RUN   TestAccElasticBeanstalkEnvironment_beanstalkEnv
=== PAUSE TestAccElasticBeanstalkEnvironment_beanstalkEnv
=== RUN   TestAccElasticBeanstalkEnvironment_resource
=== PAUSE TestAccElasticBeanstalkEnvironment_resource
=== RUN   TestAccElasticBeanstalkEnvironment_tags
=== PAUSE TestAccElasticBeanstalkEnvironment_tags
=== RUN   TestAccElasticBeanstalkEnvironment_changeStack
=== PAUSE TestAccElasticBeanstalkEnvironment_changeStack
=== RUN   TestAccElasticBeanstalkEnvironment_update
=== PAUSE TestAccElasticBeanstalkEnvironment_update
=== RUN   TestAccElasticBeanstalkEnvironment_label
=== PAUSE TestAccElasticBeanstalkEnvironment_label
=== RUN   TestAccElasticBeanstalkEnvironment_settingWithJSONValue
=== PAUSE TestAccElasticBeanstalkEnvironment_settingWithJSONValue
=== RUN   TestAccElasticBeanstalkEnvironment_platformARN
=== PAUSE TestAccElasticBeanstalkEnvironment_platformARN
=== CONT  TestAccElasticBeanstalkEnvironment_basic
=== CONT  TestAccElasticBeanstalkEnvironment_tags
=== CONT  TestAccElasticBeanstalkEnvironment_label
--- PASS: TestAccElasticBeanstalkEnvironment_basic (387.97s)
=== CONT  TestAccElasticBeanstalkEnvironment_platformARN
--- PASS: TestAccElasticBeanstalkEnvironment_label (449.41s)
=== CONT  TestAccElasticBeanstalkEnvironment_settingWithJSONValue
--- PASS: TestAccElasticBeanstalkEnvironment_tags (526.05s)
=== CONT  TestAccElasticBeanstalkEnvironment_update
--- PASS: TestAccElasticBeanstalkEnvironment_settingWithJSONValue (441.02s)
=== CONT  TestAccElasticBeanstalkEnvironment_cnamePrefix
--- PASS: TestAccElasticBeanstalkEnvironment_platformARN (647.73s)
=== CONT  TestAccElasticBeanstalkEnvironment_resource
--- PASS: TestAccElasticBeanstalkEnvironment_update (624.86s)
=== CONT  TestAccElasticBeanstalkEnvironment_beanstalkEnv
--- PASS: TestAccElasticBeanstalkEnvironment_cnamePrefix (393.06s)
=== CONT  TestAccElasticBeanstalkEnvironment_changeStack
--- PASS: TestAccElasticBeanstalkEnvironment_resource (352.33s)
=== CONT  TestAccElasticBeanstalkEnvironment_disappears
--- PASS: TestAccElasticBeanstalkEnvironment_beanstalkEnv (417.17s)
=== CONT  TestAccElasticBeanstalkEnvironment_tier
--- PASS: TestAccElasticBeanstalkEnvironment_changeStack (479.36s)
--- PASS: TestAccElasticBeanstalkEnvironment_disappears (578.60s)
--- PASS: TestAccElasticBeanstalkEnvironment_tier (475.30s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/elasticbeanstalk	2050.511s

@ewbankkit
Copy link
Contributor

@alexknez Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit b13504c into hashicorp:main Mar 5, 2024
36 checks passed
@github-actions github-actions bot added this to the v5.40.0 milestone Mar 5, 2024
@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Mar 7, 2024
Copy link

github-actions bot commented Mar 7, 2024

This functionality has been released in v5.40.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!

Copy link

github-actions bot commented Apr 7, 2024

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 Apr 7, 2024
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. partner Contribution from a partner. service/elasticbeanstalk Issues and PRs that pertain to the elasticbeanstalk service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: elastic beanstalk environment update failed [Bug]: elasticbeanstalk environment update issue
2 participants