Har*_*ngh 3 amazon-ec2 amazon-web-services aws-cloudformation
是否可以像我们使用"Ref" : "logicalName". 我只想在其自己的属性部分中动态获取资源逻辑 ID(此处为 Instance1)。直到现在我必须硬编码资源名称。
{
"AWSTemplateFormatVersion": "2010-09-09",
"Mappings": {
"Para" : {
"Layer" : { "Instance1" : "Testing", "Instance2" : "Staging", "Instance3" : "Production" }
}
},
"Resources": {
"Instance1": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": "ami-5fb8c835",
"Tags": [
{ "Key": "Name", "Value": { "Fn::FindInMap" : [ "Para", "Name", "Instance1" ]} }
]
}
},
"Instance2": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": "ami-5fb8c835",
"Tags": [
{ "Key": "Name", "Value": { "Fn::FindInMap" : [ "Para", "Name", "Instance2" ]} }
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
我只想在键、值标记行中获取资源名称(例如 Instance1 或实例 2)。
无法在自定义标签中检索逻辑名称本身,但 CloudFormation 会自动使用标签标记每个实例aws:cloudformation:logical-id。
除了您定义的任何标签之外,AWS CloudFormation 还会自动创建以下带有前缀 aws:: 的堆栈级标签:
- aws:cloudformation:logical-id
- aws:cloudformation:stack-id
- aws:cloudformation:stack-name
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html
| 归档时间: |
|
| 查看次数: |
6027 次 |
| 最近记录: |