简体   繁体   English

如何捕获 CloudFormation 堆栈 CREATE_COMPLETED 事件并处理它?

[英]How can I catch CloudFormation stack CREATE_COMPLETED event and handle it?

I am creating CloudFormation stack and Lambda that I want to be invoked once stack creation has been completed (stack gained CREATE_COMPLETED status).我正在创建 CloudFormation 堆栈和 Lambda,我想在堆栈创建完成后调用它们(堆栈获得 CREATE_COMPLETED 状态)。 Lambda is not stack resource, but this can be changed to achieve result if needed. Lambda 不是堆栈资源,但​​如果需要,可以更改它以实现结果。

Is it possible to catch this event for stack using CloudWatchRule?是否可以使用 CloudWatchRule 为堆栈捕获此事件?

Currently I am able to catch stack resources creation events, but not stack creation itself.目前我能够捕获堆栈资源创建事件,但不能捕获堆栈创建本身。

Similar questions include approaches of subscribing CloudFormationTemplate to SNS topic, however this triggers SNS on each stack resource status change, but not stack itself.类似的问题包括将 CloudFormationTemplate 订阅到 SNS 主题的方法,但是这会在每个堆栈资源状态更改时触发 SNS,而不是堆栈本身。

Given this, Lambda will be invoked on each resource change, which doesnt tell anything about whole template status.鉴于此,Lambda 将在每次资源更改时被调用,它不会告诉任何关于整个模板状态的信息。

This is a duplicate of How to send SNS notification after cloud formation is completed?这是云形成完成后如何发送 SNS 通知的副本 and Is it possible to trigger a lambda on creation from CloudFormation template 是否可以在从 CloudFormation 模板创建时触发 lambda

CloudWatch Rules is not the solution here as Rules are triggered by limited set of services or API calls. CloudWatch 规则不是这里的解决方案,因为规则是由有限的一组服务或 API 调用触发的。 (see the list here https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/EventTypes.html ) (请参阅此处的列表https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/EventTypes.html

The solution is to hook your Cloudformation tempate to an SNS topic (see doc here https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/US_SetupSNS.html ) and link SNS to a Lambda function.解决方案是将您的 Cloudformation 模板与 SNS 主题挂钩(请参阅此处的文档https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/US_SetupSNS.html )并将 SNS 链接到 Lambda 函数。

You will receive message like the below您将收到如下消息

StackId='arn:aws:cloudformation:eu-west-1:99999999999:stack/test/b08a8460-368c-11e9-be1f-025fe09a8a16'
Timestamp='2019-02-22T10:30:41.127Z'
EventId='e710f3c0-368c-11e9-b22d-06366d428b7a'
LogicalResourceId='test'
Namespace='486652066693'
PhysicalResourceId='arn:aws:cloudformation:eu-west-1:486652066693:stack/test/b08a8460-368c-11e9-be1f-025fe09a8a16'
PrincipalId='AID....6SK'
ResourceProperties='null'
ResourceStatus='CREATE_COMPLETE'
ResourceStatusReason=''
ResourceType='AWS::CloudFormation::Stack'
StackName='test'
ClientRequestToken='Console-CreateStack-c305c793-9a83-b175-bd26-f251aee30adc' 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为特定 CloudFormation 堆栈创建“aws.cloudformation”CloudWatch 事件类型? - How can I create an "aws.cloudformation" CloudWatch event type for a specific CloudFormation stack? 如何创建一个通过Boto查找CloudFormation堆栈的UUID的Python方法? - How can I create a Python method that finds the UUID of a CloudFormation stack with Boto? 我如何运行AWS Lambda函数以使我知道CloudFormation已完成整个堆栈的创建 - How do I run a AWS Lambda function to let me know that CloudFormation has completed the entire stack creation 如何在 bash 中等待 AWS CloudFormation 堆栈创建或更新完成? - How to wait until an AWS CloudFormation stack creation or update is completed in bash? 我可以在 CloudFormation 模板中创建 CloudWatch 计划事件吗? - Can I create a CloudWatch scheduled event in CloudFormation template? 如何将现有资源链接到 cloudformation 堆栈? - How can I link an existing resource to cloudformation stack? 如何通过 output 名称获取 cloudformation 堆栈? - How can I get cloudformation stack by an output name? 如何在单个CloudFormation堆栈上创建2个AWS Lambda? - How to create 2 AWS lambdas on a single CloudFormation stack? 如何使用 CloudFormation 创建这个 DynamoDb 表组? - how can I create this DynamoDb table group with CloudFormation? 如何在Cloudformation模板参数中创建IAM角色下拉列表 - How can I create IAM Role Dropdown in Cloudformation Template Parameters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM