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

feat: add sqs and sns policies based on destination config #1299

Merged
merged 8 commits into from
Dec 5, 2019

Conversation

ShreyaGangishetty
Copy link

@ShreyaGangishetty ShreyaGangishetty commented Dec 5, 2019

Issue #, if available:
SAM expects the users to define sqs:SendMessage and sns:publish policies when DestinationConfig property is set for Kinesis and DynamoDb event types (documentation).

Description of changes:
This PR removes the need to specify these policies explicitly if a property Type is specified by the user in OnFailure property of DestinationConfig.

If Type is not given users have to specify the policiles explicitly. Hence, this change is backwards compatible.

Description of how you validated changes:
Deployed the template and verified if the right policies are added and also verified if the DestinationConfig is displayed without Type parameter in the console

Checklist:

  • Write/update tests
  • make pr passes
  • Update documentation
  • Verify transformed template deploys and application functions as expected
  • Add/update example to examples/2016-10-31

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

@classmethod
def sqs_send_message_role_policy(cls, queue_arn, logical_id):
document = {
'PolicyName': 'SQSPublishPolicy' + logical_id,
Copy link
Author

Choose a reason for hiding this comment

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

Should I change the naming convention to logical_id + SQSPublishPolicy?

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the existing convention?

Copy link
Author

@ShreyaGangishetty ShreyaGangishetty Dec 5, 2019

Choose a reason for hiding this comment

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

existing convention is FunctioRole logical_id+ 'Policy'+'integer number'. But I cannot follow this convention as it might conflict with the explicit Policies section.
logical_id is Functioname+EventName

Copy link
Author

@ShreyaGangishetty ShreyaGangishetty Dec 5, 2019

Choose a reason for hiding this comment

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

updated the policy name to <eventlogicalid> + <sqspolicy/snspolicy>

@@ -61,30 +64,35 @@
],
"Policies": [
{
"PolicyName": "MyFunctionForBatchingExampleRolePolicy0",
"PolicyName": "SQSPublishPolicyMyFunctionForBatchingExampleDynamoDBStreamEvent",
Copy link
Author

Choose a reason for hiding this comment

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

SQSPublishPolicyMyFunctionForBatchingExampleDynamoDBStreamEvent will be changed as MyFunctionForBatchingExampleDynamoDBStreamEventSQSPublishRolePolicy

@codecov-io
Copy link

codecov-io commented Dec 5, 2019

Codecov Report

Merging #1299 into develop will decrease coverage by 0.22%.
The diff coverage is 64.51%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1299      +/-   ##
===========================================
- Coverage    94.61%   94.39%   -0.23%     
===========================================
  Files           78       78              
  Lines         4252     4280      +28     
  Branches       844      854      +10     
===========================================
+ Hits          4023     4040      +17     
- Misses         110      114       +4     
- Partials       119      126       +7
Impacted Files Coverage Δ
samtranslator/model/iam.py 86.36% <100%> (+5.11%) ⬆️
samtranslator/model/eventsources/pull.py 82.05% <56%> (-12.6%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9a66c83...a48b788. Read the comment docs.

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.

4 participants