aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
185 stars 62 forks source link

update error mapping to catch when Lambda layer ARN regions do not match function region #2216

Closed rtpascual closed 1 week ago

rtpascual commented 1 week ago

Problem

Work done in https://github.com/aws-amplify/amplify-backend/pull/2188 was too eager (no solid way to validate layer arn region with function region during synthesis). Reverting this change leaves us with the original error when layer arn region is not the same as function region which is not great:

The CloudFormation deployment has failed.
Caused By: The stack named <stack> failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "User: <user-arn> is not authorized to perform: lambda:GetLayerVersion on resource: <layer-arn> because no resource-based policy allows the lambda:GetLayerVersion action...

Resolution: Find more information in the CloudFormation AWS Console for this stack.

Issue number, if available:

Changes

Update error mapping with instructions to check Lambda layer ARNs and make sure regions are correct. New error message:

Unable to get layer version
Caused By: User: <user-arn> is not authorized to perform: lambda:GetLayerVersion on resource: <layer-arn> because no resource-based policy allows the lambda:GetLayerVersion action

Resolution: Make sure layer ARNs are correct and regions match function region

Corresponding docs PR, if applicable:

Validation

Unit tests.

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

changeset-bot[bot] commented 1 week ago

🦋 Changeset detected

Latest commit: 8a31b82c136be03b28abb59640de149a140f79a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages | Name | Type | | ----------------------------- | ----- | | @aws-amplify/backend | Patch | | @aws-amplify/backend-deployer | Patch | | @aws-amplify/backend-function | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR