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 an existing SQS queue option to SNS event #1231

Merged
merged 8 commits into from
Dec 13, 2019

Conversation

53ningen
Copy link
Contributor

@53ningen 53ningen commented Oct 31, 2019

readable diff:
https://github.com/awslabs/serverless-application-model/pull/1231/files?w=1

Issue #, if available:
#854

Description of changes:
Add an existing SQS queue option to SNS event

Description of how you validated changes:

  • make pr
  • verify transformed template deploys and application functions as expected

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.

@codecov-io
Copy link

codecov-io commented Oct 31, 2019

Codecov Report

Merging #1231 into develop will decrease coverage by 0.02%.
The diff coverage is 93.1%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1231      +/-   ##
===========================================
- Coverage    94.61%   94.59%   -0.03%     
===========================================
  Files           78       78              
  Lines         4252     4271      +19     
  Branches       844      846       +2     
===========================================
+ Hits          4023     4040      +17     
- Misses         110      111       +1     
- Partials       119      120       +1
Impacted Files Coverage Δ
samtranslator/model/eventsources/push.py 90.82% <93.1%> (-0.06%) ⬇️

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...4456c25. Read the comment docs.

@53ningen 53ningen force-pushed the sns-sqs-lambda branch 3 times, most recently from 20a09d8 to e50de06 Compare November 8, 2019 14:17
@53ningen 53ningen marked this pull request as ready for review November 8, 2019 14:25
@53ningen
Copy link
Contributor Author

53ningen commented Nov 8, 2019

this PR is now ready for review

@@ -392,17 +392,42 @@ def to_cloudformation(self, **kwargs):
)
return [self._construct_permission(function, source_arn=self.Topic), subscription]

# SNS -> SQS -> Lambda
# SNS -> SQS(Create New) -> Lambda
if isinstance(self.SqsSubscription, bool):
Copy link
Contributor Author

@53ningen 53ningen Nov 8, 2019

Choose a reason for hiding this comment

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

if isinstance(self.SqsSubscription, bool) is True, then self.SqsSubscription is always True, because we checked if self.SqsSubscription is False on L388

Copy link

@ShreyaGangishetty ShreyaGangishetty left a comment

Choose a reason for hiding this comment

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

@53ningen Thank you for contributing this feature!! This looks great. I have minor comments about adding a unit test and also on throwing errors when QueueArn or QueueUrl are not given.
Could you please add/update any of the existing unit tests for a condition where SqsSubscritption: False.

samtranslator/model/eventsources/push.py Show resolved Hide resolved
@timoschilling
Copy link
Contributor

timoschilling commented Nov 12, 2019

The informations of QueueArn and QueueUrl seams to be redundant. Isn't it possible to build the QueueUrl from the QueueArn, so that we only need to configure one of them?

@chrisoverzero
Copy link
Contributor

@timoschilling Gominingen described why this was sometimes not possible (and why a separate URL can be a feature) back in the original issue. In short, QueueArn is rarely going to be a string. It will almost always be an object with a key of Fn::GetAtt.

I can imagine that and similar being features of the next round of the, uh, feature:

  • If no QueueUrl specified:
    • If QueueArn is string, construct URL as string.
    • If it is Fn::GetAtt object, get logical ID, construct Ref object.
    • Bail on other intrinsics.

…which sound like really nice checks, assuming I haven’t forgotten why they’re impossible.

self.sns_event_source.SqsSubscription = sqsSubscription
self.assertRaises(TypeError, self.sns_event_source.to_cloudformation)

def test_to_cloudformation_when_sqs_subscription_disable(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you please add/update any of the existing unit tests for a condition where SqsSubscritption: False.

I've added on this line.

@53ningen
Copy link
Contributor Author

53ningen commented Dec 5, 2019

@ShreyaGangishetty
Thank very much you for reviewing this PR and I'm sorry for my late response.
I have addressed your pull request comments.

Ready for review again.

Copy link

@ShreyaGangishetty ShreyaGangishetty left a comment

Choose a reason for hiding this comment

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

@53ningen Thank you for addressing my comments. This PR looks good to me!!

Copy link
Contributor

@praneetap praneetap left a comment

Choose a reason for hiding this comment

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

Thanks a ton for submitting this feature!

@praneetap praneetap merged commit 30e33b4 into aws:develop Dec 13, 2019
@ljacobsson
Copy link
Contributor

What's the status on this?

It looks like it was included in the v1.20.0 release, but I can't get it working and failing on this line. I've even tried to define both QueueArn and QueueUrl

Also, there's no sign of this feature in the documentation.

@chrisoverzero
Copy link
Contributor

Also, there's no sign of this feature in the documentation.

It is in the documentation and specification.

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.

7 participants