如何解决带有 SNS 的 CloudFormation 模板
我正在尝试使用 CloudFormation 创建模板。 我已经在没有 CF 的情况下完成了它,但为了继续进行该项目,我需要使用 CF 来完成。
我想要实现的是一个 Lambda,它可以检索文件并将它们放入 S3 存储桶中,这是一个 SNS 主题,一旦 S3 存储桶发生更改,它将触发另一个 lambda。
看起来很简单,但我是 AWS 的新手并且仍在研究它。这就是我迄今为止所做的。
AWstemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
MemorySize: 128
Timeout: 15
Resources:
# S3 Bucket
S3Bucket:
Type: AWS::S3::Bucket
# Functions
DataTransformer:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: lambda.handler
Description: Function that is called when a file is stored in S3.
Runtime: nodejs12.x
Events:
S3Bucket:
Type: S3
Properties:
Bucket: !Ref S3Bucket
Events: 's3:ObjectCreated:*'
DataRetriever:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: lambda.handler
Description: Function that is called when a file is stored in S3.
Runtime: nodejs12.x
Events:
S3Bucket:
Type: S3
Properties:
Bucket: !Ref S3Bucket
Events: 's3:ObjectCreated:*'
# Permissions
DataTransformerPermission:
Type: AWS::Lambda::Permission
Properties:
Action: 'lambda:InvokeFunction'
FunctionName: !Ref DataTransformer
Principal: s3.amazonaws.com
SourceArn: !GetAtt S3Bucket.Arn
DataRetrieverPermission:
Type: AWS::Lambda::Permission
Properties:
Action: 'lambda:InvokeFunction'
FunctionName: !Ref DataRetriver
Principal: s3.amazonaws.com
SourceArn: !GetAtt S3Bucket.Arn
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。