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

created sns-sqs-lambda cfn serverless pattern #1505

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions sns-sqs-lambda/SNS_SQS_Lambda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
AWSTemplateFormatVersion: 2010-09-09
Resources:
SNSTopic:
Type: 'AWS::SNS::Topic'
Properties:
TopicName: SNSServerLessPatternTopic
Subscription:
- Endpoint:
Fn::GetAtt:
- "MyQueueServerLessPattern"
- "Arn"
Protocol: "sqs"
Metadata:
'AWS::CloudFormation::Designer':
id: 4a1dceb8-54fd-4790-9df0-d6f4dbed73ad
MyQueueServerLessPattern:
Type: 'AWS::SQS::Queue'
Properties:
QueueName : ServerLessPatternQueue
VisibilityTimeout: 720
LambdaFunction:
Type: 'AWS::Lambda::Function'
Properties:
Handler: LambdaFunctoin.handler
Role: !GetAtt LambdaExecutionRole.Arn
Runtime: python3.7
Timeout: 120
MemorySize: 512
Code :
ZipFile : |
import json
def lambda_handler(event, context):
print(event)
LambdaExecutionRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- 'sts:AssumeRole'
ManagedPolicyArns :
- 'arn:aws:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole'
EventSourceMapping:
Type: AWS::Lambda::EventSourceMapping
Properties:
FunctionName: !GetAtt LambdaFunction.Arn
EventSourceArn: !GetAtt MyQueueServerLessPattern.Arn
25 changes: 25 additions & 0 deletions sns-sqs-lambda/read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
SNS SQS LAMBDA

This project contains source code and supporting files for a serverless application that you can deploy with the AWS Cloudformation. It includes the following files and folders.

The project creates a SNS Topic and Subscribes a SQS Queue to it. The Subscribed SQS Queue is polled by Lambda Event Source Mapping and invokes the Lambda function with the messages present in the queue.

Requirements

Create an AWS account if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.

AWS CLI installed and configured

Git Installed

Deployment Instructions
Create a new directory, navigate to that directory in a terminal and clone the GitHub repository:

git clone https://github.com/aws-samples/serverless-patterns
Change directory to the pattern directory:

cd sns-sqs-lambda

From the command line, use AWS CLI to deploy the AWS resources for the pattern as specified in the main.tf file:

aws cloudformation create-stack --stack-name myteststack --template-body file://SNS_SQS_Lambda.yaml