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/lambda_layer_version: fix ForceNew issue with source_code_hash attribute #37646

Merged
merged 6 commits into from
May 23, 2024

Conversation

johnsonaj
Copy link
Contributor

@johnsonaj johnsonaj commented May 22, 2024

Description

Code hash returned from AWS could sometimes be different from the configuration. This causes perpetual drift and forces a resource replacement, even when the source code has not changed.

  • source_code_hash is a virtual attribute used to force a resource replacement if the code changes.
  • code_sha256 attribute has been added and contains the hash that is returned from AWS.

Relations

Closes #17989

References

Output from Acceptance Testing

% make testacc TESTARGS="-run=TestAccLambdaLayerVersion" PKG=lambda

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.2 test ./internal/service/lambda/... -v -count 1 -parallel 20  -run=TestAccLambdaLayerVersion -timeout 360m
--- PASS: TestAccLambdaLayerVersionPermission_basic_byARN (23.71s)
--- PASS: TestAccLambdaLayerVersionPermission_account (28.01s)
--- PASS: TestAccLambdaLayerVersion_s3 (29.43s)
--- PASS: TestAccLambdaLayerVersionDataSource_version (35.35s)
--- PASS: TestAccLambdaLayerVersion_basic (42.25s)
--- PASS: TestAccLambdaLayerVersion_description (51.50s)
--- PASS: TestAccLambdaLayerVersionDataSource_basic (55.49s)
--- PASS: TestAccLambdaLayerVersion_disappears (64.44s)
--- PASS: TestAccLambdaLayerVersionPermission_disappears (77.86s)
--- PASS: TestAccLambdaLayerVersionPermission_basic_byName (85.53s)
--- PASS: TestAccLambdaLayerVersion_compatibleRuntimes (89.72s)
--- PASS: TestAccLambdaLayerVersionPermission_org (94.52s)
--- PASS: TestAccLambdaLayerVersion_licenseInfo (98.56s)
--- PASS: TestAccLambdaLayerVersion_update (105.33s)
--- PASS: TestAccLambdaLayerVersionPermission_skipDestroy (109.13s)
--- PASS: TestAccLambdaLayerVersion_skipDestroy (117.25s)
--- PASS: TestAccLambdaLayerVersionDataSource_runtime (122.01s)
--- PASS: TestAccLambdaLayerVersion_sourceCodeHash (126.93s)
--- PASS: TestAccLambdaLayerVersion_compatibleArchitectures (149.24s)
--- PASS: TestAccLambdaLayerVersionDataSource_architectures (154.59s)
PASS
ok  	http://github.com/hashicorp/terraform-provider-aws/internal/service/lambda	159.899s

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. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/lambda Issues and PRs that pertain to the lambda service. labels May 22, 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 May 22, 2024
@johnsonaj johnsonaj added bug Addresses a defect in current functionality. enhancement Requests to existing resources that expand the functionality or scope. labels May 22, 2024
@johnsonaj johnsonaj marked this pull request as ready for review May 22, 2024 21:53
@johnsonaj johnsonaj added the documentation Introduces or discusses updates to documentation. label May 23, 2024
Copy link
Member

@jar-b jar-b 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 PKG=lambda TESTS="TestAccLambdaLayerVersion"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.2 test ./internal/service/lambda/... -v -count 1 -parallel 20 -run='TestAccLambdaLayerVersion'  -timeout 360m

--- PASS: TestAccLambdaLayerVersion_description (22.00s)
--- PASS: TestAccLambdaLayerVersion_s3 (29.23s)
--- PASS: TestAccLambdaLayerVersion_basic (30.75s)
--- PASS: TestAccLambdaLayerVersionPermission_account (49.76s)
--- PASS: TestAccLambdaLayerVersionPermission_org (53.96s)
--- PASS: TestAccLambdaLayerVersion_compatibleRuntimes (62.04s)
--- PASS: TestAccLambdaLayerVersionPermission_disappears (66.86s)
--- PASS: TestAccLambdaLayerVersionDataSource_basic (71.03s)
--- PASS: TestAccLambdaLayerVersionPermission_basic_byName (86.20s)
--- PASS: TestAccLambdaLayerVersion_disappears (91.39s)
--- PASS: TestAccLambdaLayerVersionPermission_basic_byARN (92.15s)
--- PASS: TestAccLambdaLayerVersionDataSource_version (100.52s)
--- PASS: TestAccLambdaLayerVersion_licenseInfo (108.38s)
--- PASS: TestAccLambdaLayerVersion_sourceCodeHash (109.59s)
--- PASS: TestAccLambdaLayerVersion_skipDestroy (113.86s)
--- PASS: TestAccLambdaLayerVersionPermission_skipDestroy (119.32s)
--- PASS: TestAccLambdaLayerVersionDataSource_runtime (129.98s)
--- PASS: TestAccLambdaLayerVersion_update (133.83s)
--- PASS: TestAccLambdaLayerVersion_compatibleArchitectures (151.38s)
--- PASS: TestAccLambdaLayerVersionDataSource_architectures (151.93s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/lambda     157.408s

Computed: true,
Type: schema.TypeString,
Computed: true,
Deprecated: "This attribute is deprecated and will be removed in a future major version. Use `code_sha256` instead.",
Copy link
Member

Choose a reason for hiding this comment

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

Good catch 👍

@johnsonaj johnsonaj force-pushed the b-lambda_layer_version_hash branch from 1a3ad11 to 75ac213 Compare May 23, 2024 15:50
@johnsonaj johnsonaj merged commit f326587 into main May 23, 2024
45 checks passed
@johnsonaj johnsonaj deleted the b-lambda_layer_version_hash branch May 23, 2024 16:31
@github-actions github-actions bot added this to the v5.51.0 milestone May 23, 2024
github-actions bot pushed a commit that referenced this pull request May 23, 2024
Copy link

This functionality has been released in v5.51.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 May 24, 2024
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 Jun 23, 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. documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/lambda Issues and PRs that pertain to the lambda service. size/XS 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.

Terraform does not accept source_code_hash
2 participants