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

fix: multiple mq source event policy name (add DynamicPolicyName) #2953

Merged
merged 10 commits into from
Feb 27, 2023

Conversation

ssenchenko
Copy link
Contributor

Issue #, if available

#2927

Description of changes

Historically, policy name was hardcoded as SamAutoGeneratedAMQPolicy but it led to a policy name clash and failure to deploy, if a Function had at least 2 MQ event sources. Since policy is attached to the Lambda execution role, policy name should be based on MQ logical ID not to clash with policy names of other MQ event sources. However, to support backwards compatibility, we need to keep policy SamAutoGeneratedAMQPolicy by default, because customers might have code which relies on that policy name consistance.

To support both old policy name and ability to have more than one MQ event source, we introduce new DynamicPolicyName which when set to true will use MQ logical ID to genertae policy name.

Q: Why to introduce a new field and not to make policy name dynamic by default if there are multiple MQ event sources?
A: Since a customer could have a single MQ source and rely on it's policy name in their code. If that customer decides to add a new MQ source, they don't want to change the policy name for the first MQ all over their code base. But they can opt in using a dynamic policy name for all other MQ sources they add.

Q: Why not use dynamic policy names automatically for all MQ event sources but first?
A: SAM-T doesn't have state and doesn't know what was the CFN resource attribute in a previous transformation. Hence, trying to "use dynamic policy names automatically for all MQ event sources but first" can rely only on event source order. If a customer added a new MQ source before an old one, an old one would receive a dynamic name and would break (potentially) customer's code.

Description of how you validated changes

Checklist

Examples?

Please reach out in the comments if you want to add an example. Examples will be
added to sam init through aws/aws-sam-cli-app-templates.

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

@ssenchenko ssenchenko requested a review from a team as a code owner February 27, 2023 05:04
@hoffa hoffa changed the title fix: multiple mq source event policy name fix: multiple mq source event policy name (add DynamicPolicyName) Feb 27, 2023
@ssenchenko ssenchenko merged commit 236fdc8 into aws:develop Feb 27, 2023
GavinZZ pushed a commit to GavinZZ/serverless-application-model that referenced this pull request Mar 2, 2023
…ws#2953)

Co-authored-by: Christoffer Rehn <1280602+hoffa@users.noreply.github.com>
@ssenchenko ssenchenko deleted the fix-policy-name branch March 21, 2023 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants