Reputation: 121
I can't find a way to make this SNS topic trigger my lambda in this cloudformation script, the stack gets created successfuly, the lambda is added as a subscriber to the SNS Topic, but i can't figure out ho to add theh SNS Topic as a trigger to the lambda from within the script, when an alarm sends an event into the topic, the lambda doesn't get triggered at all
Resources:
TriggerTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: TRIGGER_TOPIC
Subscription:
- Protocol: lambda
Endpoint: !GetAtt TriggerLambda.Arn
TriggerLambda:
Type: AWS::Lambda::Function
Properties:
Code:
S3Bucket: !Ref LambdaS3Bucket
S3Key: !Ref LambdaS3Key
Handler: !Ref LambdaHandler
Runtime: java8
Description: Trigger lambda
MemorySize: 512
Timeout: 30
Role: !GetAtt LambdaRole.Arn
LambdaRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
- 'arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole'
- 'arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess'
- 'arn:aws:iam::aws:policy/AWSLambdaReadOnlyAccess'
- 'arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess'
Upvotes: 2
Views: 1578
Reputation: 100
Check out this question: Triggering a lambda from SNS using cloud-formation?
You need to allow SNS to trigger lambda using AWS::Lambda::Permission
Upvotes: 2