How to send SNS notification after cloud formation

2019-03-25 19:24发布

Is it possible to send a SNS notification after the CFT completion in AWS ? Is there any way to get the progress of the launching CFT in AWS.

3条回答
不美不萌又怎样
2楼-- · 2019-03-25 20:12

You cannot specify notification ARNs via a CloudFormation template itself. You can specify them if you use the console to create the stack creation. But you cannot use the console to update the ARNs once the stack has been created. You can, however, use aws-cli to update the stack with notifications ARNs once it has been created, eg:

aws cloudformation update-stack --stack-name stack-name --use-previous-template --notification-arns "arn:aws:sns:us-east-1:${ACCOUNT_ID}:${TOPIC_NAME}"

Replace the variable ${VARIABLE} with the literal values from your account.

查看更多
祖国的老花朵
3楼-- · 2019-03-25 20:13

When create resources using a CF template there is an Advanced section of the Options menu. From there you can set Notification options using SNS and Topics.

When you start the CF process you can also view the status and importantly where the template might have failed.

enter image description here

enter image description here

查看更多
手持菜刀,她持情操
4楼-- · 2019-03-25 20:15

You can trick CloudFormation into sending SNS messages from inside the template:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html

Custom resources enable you to write custom provisioning logic in templates that AWS CloudFormation runs anytime you create, update (if you changed the custom resource), or delete stacks. For example, you might want to include resources that aren't available as AWS CloudFormation resource types. You can include those resources by using custom resources. That way you can still manage all your related resources in a single stack.

Use the AWS::CloudFormation::CustomResource or Custom::String resource type to define custom resources in your templates. Custom resources require one property: the service token, which specifies where AWS CloudFormation sends requests to, such as an Amazon SNS topic.

查看更多
登录 后发表回答