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

r/aws_lambda_invocation: add state upgrader for pre-v5.1.0 upgrades #40958

Merged
merged 2 commits into from
Jan 16, 2025

Conversation

jar-b
Copy link
Member

@jar-b jar-b commented Jan 15, 2025

Description

This state upgrader will prevent unintended invocations when upgrading a pre-v5.1.0 version of the aws_lambda_invocation resource to the latest version of the provider. Because we cannot retroactively apply this state upgrader to versions v5.1.0-v5.83.0, those versions will continue to see a single errant invocation when the input does not change but the version is upgraded to one in the impacted series. Upgrades to v5.84.0 (the version in which this fix is applied) and above should properly upgrade the state and prevent any unintended invocations from occurring.

This fix will also prevent issues upgrading a pre-v5.1.0 version of the aws_lambda_invocation resource with inputs that cannot be marshaled into a map[string]interface{} (e.g. an array).

% make testacc PKG=lambda TESTS=TestAccLambdaInvocation_UpgradeState_
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.3 test ./internal/service/lambda/... -v -count 1 -parallel 20 -run='TestAccLambdaInvocation_UpgradeState_'  -timeout 360m -vet=off
2025/01/15 16:13:42 Initializing Terraform AWS Provider...

--- PASS: TestAccLambdaInvocation_UpgradeState_Pre_v5_1_0 (45.26s)
--- PASS: TestAccLambdaInvocation_UpgradeState_v5_83_0 (53.68s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/lambda     60.107s

Relations

Closes #40954
Closes #31786
Relates #29367

Output from Acceptance Testing

% make testacc PKG=lambda TESTS=TestAccLambdaInvocation_
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.3 test ./internal/service/lambda/... -v -count 1 -parallel 20 -run='TestAccLambdaInvocation_'  -timeout 360m -vet=off
2025/01/15 16:31:09 Initializing Terraform AWS Provider...

--- PASS: TestAccLambdaInvocation_lifecycle_scopeCreateOnlyUpdateInput (38.50s)
--- PASS: TestAccLambdaInvocation_UpgradeState_Pre_v5_1_0 (47.29s)
--- PASS: TestAccLambdaInvocation_lifecycle_scopeCRUDCreate (48.96s)
--- PASS: TestAccLambdaInvocation_lifecycle_scopeCRUDDestroy (52.95s)
--- PASS: TestAccLambdaInvocation_qualifier (55.09s)
--- PASS: TestAccLambdaInvocation_UpgradeState_v5_83_0 (55.16s)
--- PASS: TestAccLambdaInvocation_triggers (58.94s)
--- PASS: TestAccLambdaInvocation_basic (60.94s)
--- PASS: TestAccLambdaInvocation_complex (73.41s)
--- PASS: TestAccLambdaInvocation_lifecycle_scopeCreateOnlyToCRUD (76.03s)
--- PASS: TestAccLambdaInvocation_terraformKey (79.90s)
--- PASS: TestAccLambdaInvocation_lifecycle_scopeCRUDUpdateInput (98.94s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/lambda     105.431s

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 tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/lambda Issues and PRs that pertain to the lambda service. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. labels Jan 15, 2025
@jar-b jar-b force-pushed the b-lambda_invocation-createonly-update branch from 9af6a51 to 93fe2a3 Compare January 15, 2025 21:41
This state upgrader will prevent unintended invocations when upgrading a pre-`v5.1.0` version of the `aws_lambda_invocation` resource to the latest version of the provider. Because we cannot retroactively apply this state upgrader to versions `v5.1.0`-`v5.83.0`, those versions will continue to see a single errant invocation when the configuration does not change but the version is upgraded to one in the impacted series. Upgrades to `v5.84.0` (the version in which this fix is applied) and above should properly upgrade the state and prevent any unintended invocations from occurring.

This fix will also prevent issues upgrading a pre-`v5.1.0` version of the `aws_lambda_invocation` resource with `inputs` that cannot be marshaled into a `map[string]interface{}` (e.g. an array).

```console
% make testacc PKG=lambda TESTS=TestAccLambdaInvocation_UpgradeState_
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.3 test ./internal/service/lambda/... -v -count 1 -parallel 20 -run='TestAccLambdaInvocation_UpgradeState_'  -timeout 360m -vet=off
2025/01/15 16:13:42 Initializing Terraform AWS Provider...

--- PASS: TestAccLambdaInvocation_UpgradeState_Pre_v5_1_0 (45.26s)
--- PASS: TestAccLambdaInvocation_UpgradeState_v5_83_0 (53.68s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/lambda     60.107s
```

```console
% make testacc PKG=lambda TESTS=TestAccLambdaInvocation_
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.3 test ./internal/service/lambda/... -v -count 1 -parallel 20 -run='TestAccLambdaInvocation_'  -timeout 360m -vet=off
2025/01/15 16:31:09 Initializing Terraform AWS Provider...

--- PASS: TestAccLambdaInvocation_lifecycle_scopeCreateOnlyUpdateInput (38.50s)
--- PASS: TestAccLambdaInvocation_UpgradeState_Pre_v5_1_0 (47.29s)
--- PASS: TestAccLambdaInvocation_lifecycle_scopeCRUDCreate (48.96s)
--- PASS: TestAccLambdaInvocation_lifecycle_scopeCRUDDestroy (52.95s)
--- PASS: TestAccLambdaInvocation_qualifier (55.09s)
--- PASS: TestAccLambdaInvocation_UpgradeState_v5_83_0 (55.16s)
--- PASS: TestAccLambdaInvocation_triggers (58.94s)
--- PASS: TestAccLambdaInvocation_basic (60.94s)
--- PASS: TestAccLambdaInvocation_complex (73.41s)
--- PASS: TestAccLambdaInvocation_lifecycle_scopeCreateOnlyToCRUD (76.03s)
--- PASS: TestAccLambdaInvocation_terraformKey (79.90s)
--- PASS: TestAccLambdaInvocation_lifecycle_scopeCRUDUpdateInput (98.94s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/lambda     105.431s
```
@jar-b jar-b force-pushed the b-lambda_invocation-createonly-update branch from 93fe2a3 to 9e848c0 Compare January 16, 2025 01:24
@jar-b jar-b marked this pull request as ready for review January 16, 2025 01:24
@jar-b jar-b requested a review from a team as a code owner January 16, 2025 01:24
.changelog/40958.txt Outdated Show resolved Hide resolved
Co-authored-by: Kit Ewbank <[email protected]>
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=TestAccLambdaInvocation_' PKG=lambda ACCTEST_PARALLELISM=3
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.3 test ./internal/service/lambda/... -v -count 1 -parallel 3  -run=TestAccLambdaInvocation_ -timeout 360m -vet=off
2025/01/16 10:33:49 Initializing Terraform AWS Provider...
=== RUN   TestAccLambdaInvocation_basic
=== PAUSE TestAccLambdaInvocation_basic
=== RUN   TestAccLambdaInvocation_qualifier
=== PAUSE TestAccLambdaInvocation_qualifier
=== RUN   TestAccLambdaInvocation_complex
=== PAUSE TestAccLambdaInvocation_complex
=== RUN   TestAccLambdaInvocation_triggers
=== PAUSE TestAccLambdaInvocation_triggers
=== RUN   TestAccLambdaInvocation_lifecycle_scopeCRUDCreate
=== PAUSE TestAccLambdaInvocation_lifecycle_scopeCRUDCreate
=== RUN   TestAccLambdaInvocation_lifecycle_scopeCRUDUpdateInput
=== PAUSE TestAccLambdaInvocation_lifecycle_scopeCRUDUpdateInput
=== RUN   TestAccLambdaInvocation_lifecycle_scopeCreateOnlyUpdateInput
=== PAUSE TestAccLambdaInvocation_lifecycle_scopeCreateOnlyUpdateInput
=== RUN   TestAccLambdaInvocation_lifecycle_scopeCRUDDestroy
=== PAUSE TestAccLambdaInvocation_lifecycle_scopeCRUDDestroy
=== RUN   TestAccLambdaInvocation_lifecycle_scopeCreateOnlyToCRUD
=== PAUSE TestAccLambdaInvocation_lifecycle_scopeCreateOnlyToCRUD
=== RUN   TestAccLambdaInvocation_terraformKey
=== PAUSE TestAccLambdaInvocation_terraformKey
=== RUN   TestAccLambdaInvocation_UpgradeState_Pre_v5_1_0
=== PAUSE TestAccLambdaInvocation_UpgradeState_Pre_v5_1_0
=== RUN   TestAccLambdaInvocation_UpgradeState_v5_83_0
=== PAUSE TestAccLambdaInvocation_UpgradeState_v5_83_0
=== CONT  TestAccLambdaInvocation_basic
=== CONT  TestAccLambdaInvocation_lifecycle_scopeCreateOnlyUpdateInput
=== CONT  TestAccLambdaInvocation_triggers
--- PASS: TestAccLambdaInvocation_lifecycle_scopeCreateOnlyUpdateInput (37.42s)
=== CONT  TestAccLambdaInvocation_complex
--- PASS: TestAccLambdaInvocation_basic (38.58s)
=== CONT  TestAccLambdaInvocation_lifecycle_scopeCRUDUpdateInput
--- PASS: TestAccLambdaInvocation_complex (25.51s)
=== CONT  TestAccLambdaInvocation_lifecycle_scopeCRUDCreate
--- PASS: TestAccLambdaInvocation_triggers (64.67s)
=== CONT  TestAccLambdaInvocation_terraformKey
--- PASS: TestAccLambdaInvocation_lifecycle_scopeCRUDUpdateInput (48.37s)
=== CONT  TestAccLambdaInvocation_UpgradeState_v5_83_0
--- PASS: TestAccLambdaInvocation_terraformKey (26.49s)
=== CONT  TestAccLambdaInvocation_UpgradeState_Pre_v5_1_0
--- PASS: TestAccLambdaInvocation_lifecycle_scopeCRUDCreate (37.31s)
=== CONT  TestAccLambdaInvocation_qualifier
--- PASS: TestAccLambdaInvocation_qualifier (27.68s)
=== CONT  TestAccLambdaInvocation_lifecycle_scopeCreateOnlyToCRUD
--- PASS: TestAccLambdaInvocation_UpgradeState_Pre_v5_1_0 (62.88s)
=== CONT  TestAccLambdaInvocation_lifecycle_scopeCRUDDestroy
--- PASS: TestAccLambdaInvocation_UpgradeState_v5_83_0 (68.18s)
--- PASS: TestAccLambdaInvocation_lifecycle_scopeCreateOnlyToCRUD (33.86s)
--- PASS: TestAccLambdaInvocation_lifecycle_scopeCRUDDestroy (36.31s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/lambda	195.659s

@jar-b jar-b merged commit 0ae0f39 into main Jan 16, 2025
37 checks passed
@jar-b jar-b deleted the b-lambda_invocation-createonly-update branch January 16, 2025 18:13
@github-actions github-actions bot added this to the v5.84.0 milestone Jan 16, 2025
terraform-aws-provider bot pushed a commit that referenced this pull request Jan 16, 2025
Copy link

This functionality has been released in v5.84.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 github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service/lambda Issues and PRs that pertain to the lambda service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
2 participants