gpt4 book ai didi

amazon-web-services - 从 cloudformation 中的 SNS 主题触发 lambda

转载 作者:行者123 更新时间:2023-12-03 07:14:12 32 4
gpt4 key购买 nike

我找不到一种方法让这个 SNS 主题在这个 cloudformation 脚本中触发我的 lambda,堆栈创建成功,lambda 被添加为 SNS 主题的订阅者,但我不知道如何从脚本中将 SNS 主题添加为 lambda 的触发器,当警报将事件发送到主题时,lambda 根本不会被触发

  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'

最佳答案

看看这个问题: Triggering a lambda from SNS using cloud-formation?

您需要允许 SNS 使用 AWS::Lambda::Permission 触发 lambda

关于amazon-web-services - 从 cloudformation 中的 SNS 主题触发 lambda,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66137981/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com