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

fix: Add nil check for empty blocks to fix crashes for aws_ecs_cluster #36341

Merged

Conversation

acwwat
Copy link
Contributor

@acwwat acwwat commented Mar 13, 2024

Description

This PR is to fix provider crashes in three locations due to empty configuration blocks (configuration, execute_command_configuration and log_configuration) being loaded as nil into the list of blocks from the config during expansion. The AWS API also seems to set a default value for the logging argument in the execute_command_configuration block, so I also had to set a default value to avoid perpetual differences.

Note: Since this is a widely used resource, I appreciate that a maintainer review this change to make sure I am not introducing any side effects. If there is anything I could do to help validate further, let me know.

Relations

Closes #36330

References

Referred to other resource code like that of aws_openserach_domain to see how similar cases are handled and follow suit.

Output from Acceptance Testing

$ make testacc TESTARGS="-run=TestAccECSCluster_" PKG=ecs
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecs/... -v -count 1 -parallel 20  -run=TestAccECSCluster_ -timeout 360m
=== RUN   TestAccECSCluster_basic
=== PAUSE TestAccECSCluster_basic
=== RUN   TestAccECSCluster_disappears
=== PAUSE TestAccECSCluster_disappears
=== RUN   TestAccECSCluster_tags
=== PAUSE TestAccECSCluster_tags
=== RUN   TestAccECSCluster_serviceConnectDefaults
=== PAUSE TestAccECSCluster_serviceConnectDefaults
=== RUN   TestAccECSCluster_containerInsights
=== PAUSE TestAccECSCluster_containerInsights
=== RUN   TestAccECSCluster_configuration
=== PAUSE TestAccECSCluster_configuration
=== CONT  TestAccECSCluster_basic
=== CONT  TestAccECSCluster_serviceConnectDefaults
=== CONT  TestAccECSCluster_tags
=== CONT  TestAccECSCluster_disappears
=== CONT  TestAccECSCluster_configuration
=== CONT  TestAccECSCluster_containerInsights
--- PASS: TestAccECSCluster_disappears (57.86s)
--- PASS: TestAccECSCluster_basic (59.06s)
--- PASS: TestAccECSCluster_tags (105.20s)
--- PASS: TestAccECSCluster_containerInsights (123.99s)
--- PASS: TestAccECSCluster_configuration (156.98s)
--- PASS: TestAccECSCluster_serviceConnectDefaults (211.64s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/ecs        211.836s

$

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/XS Managed by automation to categorize the size of a PR. service/ecs Issues and PRs that pertain to the ecs service. labels Mar 13, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Mar 13, 2024
@acwwat acwwat force-pushed the b-aws_ecs_cluster-fix_empty_block_nil_crashes branch from c5fb306 to c99de5f Compare March 13, 2024 04:57
@acwwat acwwat force-pushed the b-aws_ecs_cluster-fix_empty_block_nil_crashes branch from c99de5f to 008e409 Compare March 13, 2024 04:58
@acwwat acwwat changed the title [WIP] fix: Add nil check for empty blocks to fix crashes for aws_ecs_cluster fix: Add nil check for empty blocks to fix crashes for aws_ecs_cluster Mar 13, 2024
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 13, 2024
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=TestAccECSCluster_configuration\|TestAccECSCluster_basic' PKG=ecs ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecs/... -v -count 1 -parallel 2  -run=TestAccECSCluster_configuration\|TestAccECSCluster_basic -timeout 360m
=== RUN   TestAccECSCluster_basic
=== PAUSE TestAccECSCluster_basic
=== RUN   TestAccECSCluster_configuration
=== PAUSE TestAccECSCluster_configuration
=== CONT  TestAccECSCluster_basic
=== CONT  TestAccECSCluster_configuration
--- PASS: TestAccECSCluster_basic (31.54s)
--- PASS: TestAccECSCluster_configuration (56.06s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecs	63.134s

@ewbankkit
Copy link
Contributor

@acwwat Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit 5a6965b into hashicorp:main Mar 13, 2024
33 checks passed
@github-actions github-actions bot added this to the v5.41.0 milestone Mar 13, 2024
Copy link

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

@acwwat acwwat deleted the b-aws_ecs_cluster-fix_empty_block_nil_crashes branch March 22, 2024 06:05
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 Apr 23, 2024
@justinretzolk justinretzolk added the external-maintainer Contribution from a trusted external contributor. label Jul 29, 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. crash Results from or addresses a Terraform crash or kernel panic. external-maintainer Contribution from a trusted external contributor. service/ecs Issues and PRs that pertain to the ecs 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]: terraform-provider-aws_v5.40.0_x5 plugin crash. caused by empty aws_ecs_cluster configuration block
3 participants