我的 gitlab 存储库中有一些模板需要在传输到 S3 存储桶之前进行验证。如何让我的 gitlab ci 为整个模板目录运行 cloudformation,而不是单独命名每个模板?
我在想类似的事情
for file in /templates/*.yml; do aws cloudformation validate-template --template-body file://$file > validation.log; done
关于如何在 gitlab ci 中执行此操作有什么想法吗?
最佳答案
您可以使用 find/exec 命令来简化此操作,同时将日志重定向到文件可能不是一个好主意,因为在作业输出中更容易看到它们。
使用安装有 aws
工具的 shell 运行程序(或 docker 运行程序),您可以拥有以下脚本 block :
script:
- find path_to_templates -type f -name "*.yml" -exec aws cloudformation validate-template --template-body file://{} \;
将 path_to_templates 替换为您在存储库中的实际目录。它将对该目录中以 .yml 结尾的每个文件执行您的命令。
关于amazon-web-services - 如何对目录中的模板进行云信息验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64465643/