-
-
Save ej-acebedo/b0124252d650c7578ead9fff18f2bf7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
AWSTemplateFormatVersion: '2010-09-09' | |
Resources: | |
TDSQSQueue: | |
Type: 'AWS::SQS::Queue' | |
Properties: | |
QueueName: evfilter-sqs-demo | |
TDLambdaFunction: | |
Type: 'AWS::Lambda::Function' | |
Properties: | |
Code: | |
ZipFile: | | |
import json | |
def lambda_handler(event, context): | |
body = json.loads(event['Records'][0]['body']) | |
price = body["price"] | |
print("Price: " + "$" + str(price)) | |
Handler: index.lambda_handler | |
Role: !GetAtt TDLambdaExecutionRole.Arn | |
Runtime: python3.8 | |
Timeout: 30 | |
TDLambdaExecutionRole: | |
Type: 'AWS::IAM::Role' | |
Properties: | |
AssumeRolePolicyDocument: | |
Version: '2012-10-17' | |
Statement: | |
- Effect: Allow | |
Action: | |
- 'sts:AssumeRole' | |
Principal: | |
Service: | |
- lambda.amazonaws.com | |
Policies: | |
- PolicyName: main | |
PolicyDocument: | |
Version: '2012-10-17' | |
Statement: | |
- Effect: Allow | |
Action: | |
- 'sqs:ReceiveMessage' | |
- 'sqs:GetQueueAttributes' | |
- 'sqs:DeleteMessage' | |
Resource: !GetAtt TDSQSQueue.Arn | |
- Effect: Allow | |
Action: | |
- 'logs:CreateLogGroup' | |
Resource: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:*" | |
- Effect: Allow | |
Action: | |
- 'logs:CreateLogStream' | |
- 'logs:PutLogEvents' | |
Resource: !Sub "arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*" | |
TDEventSourceMapping: | |
Type: 'AWS::Lambda::EventSourceMapping' | |
Properties: | |
EventSourceArn: !GetAtt TDSQSQueue.Arn | |
FunctionName: !GetAtt TDLambdaFunction.Arn | |
BatchSize: 1 | |
FilterCriteria: | |
Filters: | |
- Pattern: "{\"body\":{\"price\":[ { \"numeric\": [ \">\", 50 ] } ]}}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment