[{"data":1,"prerenderedAt":68},["ShallowReactive",2],{"pattern-sns-sqs-cdk":3},{"id":4,"title":5,"architectureURL":6,"cleanup":7,"contributors":13,"deploy":15,"description":18,"extension":19,"framework":20,"gitHub":21,"highlight":6,"introBox":30,"language":34,"level":35,"meta":36,"patternArch":37,"resources":50,"s3URL":6,"services":59,"stem":60,"testing":61,"videoId":29,"__hash__":67},"patterns\u002Fpatterns\u002Fsns-sqs-cdk.json","Amazon SNS to Amazon SQS",null,{"headline":8,"text":9},"Cleanup",[10,11,12],"1. Delete the stack: \u003Ccode>npx cdk destroy\u003C\u002Fcode>.","2. Confirm the stack has been deleted: \u003Ccode>aws cloudformation list-stacks --query \"StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus\"\u003C\u002Fcode>.","3. You see a message confirming DELETE_COMPLETE.",[14],"content\u002Fcontributors\u002Fian-larson.json",{"text":16},[17],"See the GitHub repo for detailed deployment instructions.","Create an SQS queue that subscribes to an SNS topic.","json","AWS CDK",{"template":22,"payloads":27},{"projectFolder":23,"repoURL":24,"templateURL":25,"templateFile":26},"sns-sqs-cdk","https:\u002F\u002Fgithub.com\u002Faws-samples\u002Fserverless-patterns\u002Ftree\u002Fmain\u002Fsns-sqs-cdk","serverless-patterns\u002Fsns-sqs-cdk","sns_sqs_cdk\u002Fsns_sqs_cdk_stack.py",[28],{"headline":29,"payloadURL":29},"",{"headline":31,"text":32},"How it works",[33],"This CDK template deploys a SNS topic and an SQS queue. The SQS queue is subscribed to the SNS topic. SNS invokes the SQS queue when new messages are available. When messages are sent to the SNS topic, they are delivered as a JSON event payload to the SQS queue.","Python","100",{},{"icon1":38,"icon2":43,"line1":47},{"x":39,"y":40,"service":41,"label":42},20,50,"sns","SNS",{"x":44,"y":40,"service":45,"label":46},80,"sqs","SQS",{"from":48,"to":49,"label":29},"icon1","icon2",{"headline":51,"bullets":52},"Additional resources",[53,56],{"text":54,"link":55},"Choosing between messaging services for serverless applications.","https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fcompute\u002Fchoosing-between-messaging-services-for-serverless-applications\u002F",{"text":57,"link":58},"Fanout to Amazon SQS queues","https:\u002F\u002Fdocs.aws.amazon.com\u002Fsns\u002Flatest\u002Fdg\u002Fsns-sqs-as-subscriber.html",{"from":41,"to":45},"patterns\u002Fsns-sqs-cdk",{"headline":62,"text":63},"Testing",[64,65,66],"Use the AWS CLI to send a message to the SNS topic and observe the event delivered to the Lambda function:","1. Send the SNS message: \u003Ccode>aws sns publish --topic-arn ENTER_SNS_TOPIC_ARN  --subject testSubject --message testMessage\u003C\u002Fcode>.","2. Retrieve the message from the SQS queue, using the queue URL from the AWS SAM deployment outputs: \u003Ccode>aws sqs receive-message --queue-url ENTER_YOUR_QUEUE_URL\u003C\u002Fcode>.","AIcwG26Iv9EpLVfFaxqy2QaiFgEcdtYhr593QSPKLa0",1778846888128]