[英]How do I run a AWS Lambda function to let me know that CloudFormation has completed the entire stack creation
I would like to make an automated call to a custom program API as soon as CloudFormation has completed the entire stack creation (deployment of instances, setup of VPC, Puppet scripts, etc.). 我想在CloudFormation完成整个堆栈创建(实例的部署,VPC的设置,Puppet脚本等)完成后立即自动调用自定义程序API。
What is the correct way to go about this? 正确的解决方法是什么?
After some research, it seems a good option would be to launch an AWS Lambda function triggered by the event that stack creation has been completed successfully, but I have no idea how to approach this. 经过一些研究,似乎一个不错的选择是启动一个由堆栈创建成功完成的事件触发的AWS Lambda函数,但是我不知道该如何处理。
Any ideas or advice would be appreciated. 任何想法或建议,将不胜感激。
You can provision and coordinate a lot of what you're talking about (setup of VPC, etc.) with CloudFormation, the DependsOn attribute and nested CloudFormation stacks. 您可以使用CloudFormation, DependsOn属性和嵌套的CloudFormation堆栈来配置和协调许多您正在谈论的内容(VPC的设置等)。 This way you can order the execution of the CloudFormation stacks so that, for example, your VPC is created first followed by launching your EC2 instance(s) followed by the deployment of the software on the instance(s). 这样,您就可以命令执行CloudFormation堆栈,例如,首先创建VPC,然后启动EC2实例,然后在实例上部署软件。
You can also coordinate the execution of the other behavior you mentioned (deployment [on] instances, [calling] Puppet scripts, etc.) using AWS::CloudFormation::Init . 您还可以使用AWS :: CloudFormation :: Init协调所提到的其他行为(部署[on]实例,[调用] Puppet脚本等)的执行。 This way, you can call out to your Puppet scripts from your EC2 instance within the CloudFormation template. 这样,您可以从CloudFormation模板中的EC2实例中调出Puppet脚本。 The actual execution of your Puppet scripts occurs on the EC2 instance(s). Puppet脚本的实际执行发生在EC2实例上。
If you want to see an example of calling out to a configuration management tool from CloudFormation (in this case, we're using Chef Solo), see app-instance.json . 如果要查看从CloudFormation调出配置管理工具的示例(在本例中,我们使用的是Chef Solo),请参阅app-instance.json 。 If you'd like to see an example of using nested stacks, see dromedary-master.json . 如果您想查看使用嵌套堆栈的示例,请参阅dromedary-master.json 。
There's also some examples of using Lambda on our blog as well (Stelligent), but it doesn't seem like you need to use Lambda in this case based on the problem you're trying to solve. 在我们的博客上也有一些使用Lambda的示例(Stelligent),但是根据您要解决的问题,您似乎并不需要在这种情况下使用Lambda。
PS You don't have to use nested stacks either, but it can make things a little cleaner. PS你不必要么使用嵌套栈,但它可以让事情变得更清洁。 But, you do want to control the creation order of the resources so the DependsOn attribute will help you in doing so. 但是,您确实希望控制资源的创建顺序,因此DependsOn属性将帮助您做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.