fix(resources/template-writer): add IAM policy as customResource dependency #1148
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.
Issue #, if available:
Description of changes:
Resources provisioned using the construct
@aws-solutions-constructs/aws-openapigateway-lambda
succeed on initial deploy however when a modification is made to the referenced OpenAPI specification the deployment fails. Resulting in the following error.The issue is caused by
./resources/template-writer
. When the specification changes this results in a new S3 asset which is used bytemplate-writer
to update the inline IAM policy which is attached to the custom resource Lambda responsible for managing the create and update lifecycle events.However during a stack update this Lambda will fail to execute as it still references the old IAM policy and so this results in a 403 error when
await s3Client.send(new client_s3_1.GetObjectCommand ...
is attempted as the suppliedevent.ResourceProperties.TemplateInputKey
does not match the current policy.To address this the following has been added, to ensure that the policy is in place when the Lambda is executed.
customResource.node.addDependency(templateWriterPolicy);
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.