【发布时间】:2022-01-22 20:58:16
【问题描述】:
我想使用 cloudformation 将 RDS 快照导出到 s3,这将触发 lambda 函数。但我对此有点陌生。有人可以帮帮我吗。我已经为 Lambda 和 SNS 编写了脚本,但我很困惑如何使用 cloudformation 将 RDS 快照导出到 S3。我附上了从 SNS 触发 Lambda 的文件。帮助将不胜感激。谢谢。
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: >
example-lambda-sns
Example CloudFormation template to subscribe a lambda to an SNS Topic.
Resources:
ExampleTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: !Sub 'example-sns-topic'
TopicName: !Sub 'example-sns-topic'
Subscription:
- Protocol: lambda
Endpoint: !GetAtt ExampleFunction.Arn
ExampleFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: mylambdafunction
Description: mylambdafunction
Handler: index.handler
Runtime: nodejs14.x
Role: arn:aws:iam::48
CodeUri: 's3://testing/tes.zip'
ExampleFunctionInvokePermission:
Type: 'AWS::Lambda::Permission'
Properties:
Action: 'lambda:InvokeFunction'
FunctionName: !Ref ExampleFunction
Principal: sns.amazonaws.com
ExampleTopicPolicy:
Type: 'AWS::SNS::TopicPolicy'
Properties:
Topics:
- !Ref ExampleTopic
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action: 'sns:Publish'
Resource: !Ref ExampleTopic
Principal:
AWS: '*'
Condition:
ArnLike:
AWS:SourceArn: !Sub 'arn:aws:*:*:${AWS::AccountId}:*'```
【问题讨论】:
-
您是要在应用 CloudFormation 模板时导出快照,还是要使用 CloudFormation 创建一个系统,在该系统中,发布到 SNS 的消息会触发执行快照?
-
@Parsifal 我想制作一个 CloudFormation 模板,其中发布到 SNS 的消息会触发执行快照的 Lambda
标签: amazon-web-services amazon-s3 aws-lambda amazon-rds amazon-sns