amazon-web-services - `cfn-init` 在堆栈更新期间执行(configSet 的)新命令

标签 amazon-web-services aws-cloudformation

拥有一个像这样的配置集 example :

"AWS::CloudFormation::Init" : {
    "configSets" : {
        "ascending" : [ "config1" , "config2" ],
        "descending" : [ "config2" , "config1" ]
    },
    "config1" : {
        "commands" : {
            "test" : {
                "command" : "echo \"$CFNTEST\" > test.txt",
                "env" : { "CFNTEST" : "I come from config1." },
                "cwd" : "~"
            }
        }
    },
    ...
}   

如果我添加命令/修改现有命令,如下所示:

"config1" : {
        "commands" : {
            "test" : {
                "command" : "echo \"$CFNTEST\" > test.txt",
                "env" : { "CFNTEST" : "I come from config1." },
                "cwd" : "~"
            },
            "test2" : {
                "command" : "echo \"$CFNTEST\" > test2.txt",
                "env" : { "CFNTEST" : "I come from config2." },
                "cwd" : "~"
            }
        }
    }

会创建文件test2.txt吗?如果是,如果我修改 "env" 例如会发生什么?

最佳答案

如果这些命令仅在 cfn-init 期间运行,那么它们将不会在堆栈更新期间运行。只有新实例才会运行更新的命令。

您需要使用cfn-hup如果您已更新堆栈,请重新运行 cfn-init。

关于amazon-web-services - `cfn-init` 在堆栈更新期间执行(configSet 的)新命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33071308/

相关文章:

amazon-web-services - 添加堆栈时自动从堆栈转发 CW 日志

amazon-web-services - 从 AWS 实例导出 CloudFormation 堆栈并导入到另一个实例

aws-cloudformation - AWS Cloudformation 对 EKS Fargate 的支持

amazon-web-services - 如何识别定义了IAM角色的CloudFormation模板?

amazon-web-services - Elasticache Redis 自动备份到 S3

amazon-web-services - AWS 从控制台创建监听器 - 所有目标组均呈灰色

amazon-web-services - 亚马逊云服务器 : How do I get around "too many containers" with my microservice architecture API?

java - 批量将100万行CSV写入S3

amazon-web-services - Amazon EC2 是否允许安装工具?

amazon-web-services - 无法删除 AWS::ApiGateway::GatewayResponse