Amazon web services 如何获取资源逻辑id模板?

Amazon web services 如何获取资源逻辑id模板?,amazon-web-services,amazon-ec2,amazon-cloudformation,Amazon Web Services,Amazon Ec2,Amazon Cloudformation,是否可以像使用“Ref”:“logicalName”一样在资源内部获取资源的逻辑ID。我只想在它自己的属性部分动态地获取资源逻辑id(这里是Instance1)。到目前为止,我必须硬编码资源名称 { "AWSTemplateFormatVersion": "2010-09-09", "Mappings": { "Para" : { "Layer" : { "Instance1" : "Testing", "Instance2" : "Sta

是否可以像使用
“Ref”:“logicalName”
一样在资源内部获取资源的逻辑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或instance 2)。

不可能在自定义标记中检索逻辑名称本身,但CloudFormation会使用
aws:CloudFormation:logical id
标记自动标记每个实例

除了您定义的任何标记之外,AWS CloudFormation还会自动 使用前缀aws创建以下堆栈级别标记:

  • aws:cloudformation:逻辑id
  • aws:cloudformation:堆栈id
  • aws:cloudformation:堆栈名称

目前不确定这是否正确。我在堆栈中没有看到任何带有“aws:cloudformation:logical id”的标记