[英]Pass tag Key and Value for resource name in AWS Cloudformation
我有我的cloudformation json模板,該模板的資源(具體來說是VPC)標簽映射如下:
"Tags" : [ {"Key" : "Name", "Value" : "nameofresource"} ]
現在,我使用以下命令從shell腳本運行此命令
aws cloudformation create-stack --stack-name stackname --template-body file://template.json
我想通過參數傳遞名稱。 我嘗試使用
--parameters ParameterKey=Name,ParameterValue=somevalue
在我的模板之后。 但這會引發錯誤。 我也嘗試將JSON中的"Value"
替換為"Value"
"Ref" : "paramkeyvalue"
,並根據需要從cli傳遞它。 如何通過參數傳遞名稱?
將參數鍵和值名稱替換為ParameterKey和ParameterValue
--parameters ParameterKey =名稱,ParameterValue =某個值
“標簽”:[{“ ParameterKey”:“名稱”,“ ParameterValue”:“ somevalue”}]
命令:
aws cloudformation create-stack --stack-name "MyVPC" --template-body file://test.yaml --parameters ParameterKey=Name,ParameterValue="MyVPC"
test.yaml
{
"Parameters": {
"Name": {
"Type": "String",
"Default": "MyName"
}
},
"Resources": {
"myVPC": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.0.0.0/16",
"EnableDnsSupport": "false",
"EnableDnsHostnames": "false",
"InstanceTenancy": "default",
"Tags": [{
"Key": "Name",
"Value": {
"Ref": "Name"
}
}]
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.