File tree Expand file tree Collapse file tree 4 files changed +50
-0
lines changed
examples/2016-10-31/sns_sqs Expand file tree Collapse file tree 4 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ transformed-cfn-template.yaml
Original file line number Diff line number Diff line change
1
+ # SNS-SQS Event Source Example
2
+
3
+ Example SAM template for processing messages on an SNS-SQS.
4
+
5
+ ## Running the example
6
+
7
+ ``` bash
8
+ # Set YOUR_S3_ARTIFACTS_BUCKET to a bucket you own
9
+ YOUR_S3_ARTIFACTS_BUCKET=' YOUR_S3_ARTIFACTS_BUCKET' ; \
10
+ aws cloudformation package --template-file template.yaml --output-template-file cfn-transformed-template.yaml --s3-bucket $YOUR_S3_ARTIFACTS_BUCKET
11
+ aws cloudformation deploy --template-file ./cfn-transformed-template.yaml --stack-name lambda-sns-sqs-processor --capabilities CAPABILITY_IAM
12
+ ```
13
+
14
+ After your CloudFormation Stack has completed creation, send a message to the SNS topic to see it in action:
15
+
16
+ ``` bash
17
+ YOUR_SNS_TOPIC_ARN=arn:aws:sns:us-east-1:[your_account_id]:[your_topic_name]; \
18
+ aws sqs send-message --target-arn $YOUR_SNS_TOPIC_ARN --message ' { "myMessage": "Hello SAM!" }'
19
+ ```
Original file line number Diff line number Diff line change
1
+ async function handler ( event , context ) {
2
+ const records = event . Records
3
+ console . log ( records )
4
+ return { }
5
+ }
6
+
7
+ module . exports . handler = handler
Original file line number Diff line number Diff line change
1
+ AWSTemplateFormatVersion : ' 2010-09-09'
2
+ Transform : AWS::Serverless-2016-10-31
3
+ Description : Example of processing messages on an SNS-SQS with Lambda
4
+ Resources :
5
+ MyTopic :
6
+ Type : AWS::SNS::Topic
7
+ MyFunction :
8
+ Type : AWS::Serverless::Function
9
+ Properties :
10
+ CodeUri : ./index.js
11
+ Handler : index.handler
12
+ Runtime : nodejs8.10
13
+ Events :
14
+ MySQSEvent :
15
+ Type : SNS
16
+ Properties :
17
+ Topic : !Ref MyTopic
18
+ SqsSubscription : true
19
+
20
+ Outputs :
21
+ MyTopic :
22
+ Description : " MyTopic ARN"
23
+ Value : !Ref MyTopic
You can’t perform that action at this time.
0 commit comments