小编Har*_*ngh的帖子

如何获取资源逻辑id 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)

amazon-ec2 amazon-web-services aws-cloudformation

3
推荐指数
1
解决办法
6027
查看次数