【问题标题】:get cloudformation parameters from .txt file/s3 bucket从 .txt 文件/s3 存储桶获取 cloudformation 参数
【发布时间】:2018-03-16 21:33:47
【问题描述】:

我想将输入参数从文本文件传递给 cloudformation 属性,或者将文本文件保存在 s3 存储桶中,并在 CF 属性中指向 s3 URL。

请让我知道这是否可能?如果是,怎么办?

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation


    【解决方案1】:

    如果您使用 AWS 管理控制台来创建 CloudFormation 堆栈,则没有办法,但如果您使用 AWS CLI,则可以。以下列格式之一将参数保存到文本文件(例如parameters.txt)中:

    速记:

    ParameterKey=string,ParameterValue=string,UsePreviousValue=boolean ...
    

    JSON:

    [
     {
       "ParameterKey": "string",
       "ParameterValue": "string",
       "UsePreviousValue": true|false
     }
     ...
    ]
    

    然后使用 AWS CLI 命令cloudformation create-stack,例如:

    aws cloudformation create-stack --stack-name <YourStackName> \
      --template-body file://<YourTemplateFileName.ext> \
      --parameters file://parameters.txt
    

    不幸的是,--parameters 似乎不能直接引用 S3 存储桶,只能引用本地文件或内联参数。

    【讨论】:

      【解决方案2】:

      查看您使用 s3 url 传递的此博客参数:

      https://aws.amazon.com/blogs/devops/passing-parameters-to-cloudformation-stacks-with-the-aws-cli-and-powershell/

      也试试这个:

      aws cloudformation create-stack --stack-name <YourStackName> \
        --template-body file://<YourTemplateFileName.ext> \
        --parameters $(aws s3 cp S3:/yourbucketname\parameters.txt - )
      

      【讨论】:

        猜你喜欢
        • 2020-11-10
        • 2016-06-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多