How to send SNS notification after cloud formation is completed?

后端 未结 4 2075
南旧
南旧 2020-12-31 03:47

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.

相关标签:
4条回答
  • 2020-12-31 04:12

    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.

    0 讨论(0)
  • 2020-12-31 04:25

    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.

    0 讨论(0)
  • 2020-12-31 04:26

    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.

    0 讨论(0)
  • 2020-12-31 04:27

    There's also knowledge center article from AWS where you can replace ROLLBACK_IN_PROGRESS statement with any other state of CloudFormation to get SNS Notification.

    0 讨论(0)
提交回复
热议问题