CloudFormation 找不到刚刚创建的子网

CloudFormation 找不到刚刚创建的子网

我正在尝试创建一个子网,然后在其中创建一个 ENI;报告子网已创建,然后创建 ENI 失败,提示未找到子网:

16:49:06 UTC-0600 CREATE_COMPLETE AWS::EC2::Subnet subnet0 ..... 16:49:10 UTC-0600 CREATE_FAILED AWS::EC2::NetworkInterface CSReniA 子网 ID“subnet0”不存在

我使用这两个资源节:

"subnet0": {
  "Type": "AWS::EC2::Subnet",
  "Properties": {
    "CidrBlock": "10.100.0.0/24",
    "AvailabilityZone": "us-west-2a",
    "VpcId": {
      "Ref": "vpcfde3149b"
    },
    "Tags": [
      {
        "Key": "Name",
        "Value": "Base"
      }
    ]
  }
},

"CSReniA" : {
  "Type" : "AWS::EC2::NetworkInterface",
  "DependsOn": [
    "subnet0"
  ],
  "Properties" : {
    "Tags": [{"Key":"Name","Value":"CSReniA"}],
    "Description": "primary interface for CSR ingress and for transit local routes",
    "SourceDestCheck": "false",
    "GroupSet": ["sgalltraffic"],
    "SubnetId": "subnet0",
    "PrivateIpAddress": "10.100.0.30"
  }
},

有没有更好/不同的方法?任何建议都非常感谢。谢谢。

答案1

代替:

"SubnetId": "subnet0",

使用对子网资源的引用:

"SubnetId": { "Ref": "subnet0" },

那可行 :)

相关内容