gpt4 book ai didi

amazon-web-services - Cloud Formation 函数不会将值分配给标签内键的值

转载 作者:行者123 更新时间:2023-12-03 07:45:05 25 4
gpt4 key购买 nike

我有以下 Cloud Formation 模板来创建 VPC。 VPC 名称是根据创建模板的区域和环境生成的。VPC 创建时没有任何问题,并且正在运行 aws cloud formation validate-template --template-url https://foo.template不会提示任何语法。

我希望 VPC 被命名为:

vpc-uw1-d-fs

相反,VPC 的名称为空,并且名称标签的值也为空。是我没有正确使用该功能吗?如果我删除 Fn::FindInMap函数使用时,我得到了生成的名称 - 它只是缺少环境映射值。

{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "VPC for a new environment to use.",
"Parameters": {
"EnvironmentName": {
"Description": "Name of the environment that this VPC will be used for.",
"Type": "String",
"MinLength": "2",
"MaxLength": "20",
"AllowedPattern": "[a-zA-Z]*",
"AllowedValues": [
"Development",
"QA",
"Test",
"Production"
]
}
},
"Resources": {
"VPC": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.0.0.0/16",
"EnableDnsSupport": false,
"EnableDnsHostnames": false,
"InstanceTenancy": "default",
"Tags": [ {
"Key": "Name",
"Value": {
"Fn::Join": [
"-",
[
"vpc",
{ "Ref": "AWS::Region" },
{ "Fn::FindInMap": [
"EnvironmentMap", { "Ref": "EnvironmentName" }, "AbbreviatedName"
]},
"fs"
]
]
}
}]
}
}
},
"Mappings": {
"RegionMap": {
"us-east-1": {
"regionName": "ue1"
},
"us-west-1": {
"regionName": "uw1"
}
},
"EnvironmentMap": {
"Development": {
"AbbreviatedName": "d"
},
"QA": {
"AbbreviatedName": "qa"
},
"Test": {
"AbbreviatedName": "t"
},
"Production": {
"AbbreviatedName": "p"
}
}
},
"Outputs": {

}
}

最佳答案

您的模板非常适合我。

我在 ap-southeast-2 区域运行它并生成了标签:

  • 名称: vpc-ap-southeast-2-d-fs

(给定的模板中未使用 RegionMap。)

关于amazon-web-services - Cloud Formation 函数不会将值分配给标签内键的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50361434/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com