简体   繁体   English

cloudformation部署后脚本

[英]cloudformation post deployment script

I have an npm script called db:migrate that I want to run after every deployment on aws. 我有一个名为db:migrate的npm脚本,我想在aws上进行每次部署后运行。 That script runs a file called migrate.js (when present) which takes care of doing db migrations. 该脚本运行一个名为migrate.js的文件(如果存在),该文件负责进行数据库迁移。

I'm using aws cloudformation for deployments, but I'm not sure what the best way is to have some form of post deployment script that would run that script: npm run db:migrate. 我正在使用aws cloudformation进行部署,但是我不确定最好的方法是使用某种形式的后期部署脚本来运行该脚本:npm run db:migrate。

I thought there might be some form of cloudformation post deploy hook that I could use, but all I found are cloudformation custom resources. 我以为可以使用某种形式的cloudformation部署后挂钩,但是我发现的只是cloudformation定制资源。 Apparently, I could trigger a lambda function after each deployment. 显然,我可以在每次部署后触发一个lambda函数。 The problem is that I don't know how I could access the ECS container from the lambda function in order to run the db:migrate script. 问题是我不知道如何才能从lambda函数访问ECS容器以运行db:migrate脚本。

I'd appreciate any insights. 我将不胜感激。

您可以将用户数据添加到模板(EC2 /启动模板/启动配置) https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM