【发布时间】:2018-03-16 21:33:47
【问题描述】:
我想将输入参数从文本文件传递给 cloudformation 属性,或者将文本文件保存在 s3 存储桶中,并在 CF 属性中指向 s3 URL。
请让我知道这是否可能?如果是,怎么办?
【问题讨论】:
标签: amazon-web-services amazon-cloudformation
我想将输入参数从文本文件传递给 cloudformation 属性,或者将文本文件保存在 s3 存储桶中,并在 CF 属性中指向 s3 URL。
请让我知道这是否可能?如果是,怎么办?
【问题讨论】:
标签: amazon-web-services amazon-cloudformation
如果您使用 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 存储桶,只能引用本地文件或内联参数。
【讨论】:
查看您使用 s3 url 传递的此博客参数:
也试试这个:
aws cloudformation create-stack --stack-name <YourStackName> \
--template-body file://<YourTemplateFileName.ext> \
--parameters $(aws s3 cp S3:/yourbucketname\parameters.txt - )
【讨论】: