mah*_*hod 1 amazon-web-services aws-cloudformation
我试图使用以下命令更新现有的 cloudformation 堆栈。
aws cloudformation deploy
Run Code Online (Sandbox Code Playgroud)
没有选项传递参数文件与部署选项。我们尝试使用 --parameter-overrides 传递参数文件,但出现以下错误。
value passed to --parameter-overrides must be of format Key=Value
Run Code Online (Sandbox Code Playgroud)
我们尝试执行的命令是
aws cloudformation deploy --template-file sg.yml --stack-name Common-SG --parameter-overrides ip.json --no-execute-changeset
Run Code Online (Sandbox Code Playgroud)
有什么方法可以通过aws cloudformation deploy传递文件中的参数
小智 6
在本地文件中传递存储为 JSON 的参数如下所示:
aws cloudformation deploy \
--stack-name ${CI_PROJECT_NAME}-${STAGE} \
--template-file deployment.yml \
--s3-bucket ${CI_BUCKET} \
--role-arn ${DEPLOYMENT_ROLE} \
--no-fail-on-empty-changeset \
--parameter-overrides file://./env/sandbox/config-sandbox.json \
Run Code Online (Sandbox Code Playgroud)
和 config-sandbox.json 这样的。
{
"Parameters": {
"EnvironmentStage": "sandbox",
}
}
Run Code Online (Sandbox Code Playgroud)
更多详情:https : //aws.amazon.com/fr/blogs/devops/passing-parameters-to-cloudformation-stacks-with-the-aws-cli-and-powershell/
此问题的解决方法是使用jq命令传递参数。
yum install jq
Run Code Online (Sandbox Code Playgroud)
下面是相同的语法。
aws cloudformation deploy --template-file sg.yml --stack-name Common-SG --parameter-overrides $(jq -r '.[] | [.ParameterKey, .ParameterValue] | "\(.[0])=\(.[1])"' ip.json) --no-execute-changeset
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4938 次 |
| 最近记录: |