Rework of aws_lambda_layer_version_permission resource. #44668
+127
−76
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the library.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
No Changes
Description
Support for multiple
aws_lambda_layer_version_permission
resources attached to the same lambda layer version is currently non functional. Eachaws_lambda_layer_version_permission
currently assumes it is the only such resource and reads the first statement within the policy. This creates some very strange issues where you can create multiple permissions, but on the next state refresh each one will assume the attributes of the first statement created.I believe this is partly due to the very unique nature of the lambda layer permission endpoints. They are asymmetrical in their CRUD structure. This can be represented as follows:
In this PR, each permission resource still has its own state tracking of the overall policy and revision ID. This means these attributes can fall out of sync as sequential permissions are created until the next state refresh. This is not a new problem and was already present. I predict 4 options that I would like to put forward to reviewers:
policy
attribute, the full policy looks to have always been intended to be present in the state of each individual permission.My initial inclination would be the first option, which this PR represents. I believe this provides the best balance of improved function, work overhead and breaking changes. I believe the only breaking change in this PR is the import identification for the permission resource.
Relations
Closes most of the issues hinted upon within #21917
References
Documented ideal capabilities with support of multiple permission resources: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_layer_version_permission
Output from Acceptance Testing