gpt4 book ai didi

amazon-web-services - 如何获取资源逻辑id cloudformation模板?

转载 作者:行者123 更新时间:2023-12-04 02:15:42 25 4
gpt4 key购买 nike

是否可以像我们使用 "Ref": "ologicalName" 那样在其内部获取资源的逻辑 ID。我只想动态获取其自己的属性部分中的资源逻辑 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" ]} }
]
}
}
}

我只想获取键、值标记行中的资源名称(例如 Instance1 或实例 2)。

最佳答案

无法在自定义标记中检索逻辑名称本身,但 CloudFormation 会自动使用 aws:cloudformation:ological-id 标记来标记每个实例。

In addition to any tags you define, AWS CloudFormation automatically creates the following stack-level tags with the prefix 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

关于amazon-web-services - 如何获取资源逻辑id cloudformation模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33891557/

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