简体   繁体   English

我如何运行AWS Lambda函数以使我知道CloudFormation已完成整个堆栈的创建

[英]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 . 如果要查看从Cl​​oudFormation调出配置管理工具的示例(在本例中,我们使用的是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.

相关问题 如何仅在创建 AWS::Cloudformation::Stack 时调用 AWS::Lambda::Function? - How can I invoke an AWS::Lambda::Function only on the creation of a AWS::Cloudformation::Stack? 如何在 bash 中等待 AWS CloudFormation 堆栈创建或更新完成? - How to wait until an AWS CloudFormation stack creation or update is completed in bash? 如何使用一个CloudFormation堆栈中的SQS队列作为另一CloudFormation堆栈中的lambda函数的触发器? - How do I use an SQS queue in one CloudFormation stack as a trigger to a lambda function in another CloudFormation stack? 如何使用 CloudFormation 模板更新 AWS Lambda function - How do I update AWS Lambda function using CloudFormation template 如何通知用户lambda函数已完成? - How do I notify a user that a lambda function has completed? 如何在AWS实例上设置警报以在数据分析完成时通知我? - How do I set up alerts on AWS instances to let me know when my data analysis is complete? 创建Cloudformation堆栈后触发计划的Lambda函数 - Fire scheduled lambda function after cloudformation stack creation 每个堆栈更新和创建一次AWS Cloudformation运行命令 - AWS Cloudformation run command once per stack update and creation AWS CloudFormation中的Lambda函数 - Lambda Function in AWS CloudFormation 如何在整个组织中运行 AWS Lambda function - How to run an AWS Lambda function across an entire organisation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM