为什么我的子网和 VPC 在 CloudFormation 上并排显示

发布于 2025-01-19 23:47:52 字数 1587 浏览 5 评论 0原文

我一直试图弄清楚为什么我的 VPC 和子网并排显示,而不是 VPC 内部的子网? (我使用 Atom 来生成它。)

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "vpc",
    "Metadata": {

    },
    "Parameters": {"siggyVpcCidr": {
        "Description": "vpc cidr",
        "Type": "String",
        "Default": "10.0.0.0/16"
    },
    "siggySubnetCidr": {
        "Description": "cidr for the subnet",
        "Type": "String",
        "Default": "10.0.1.0/2"
    },
    "Subnet1Az": {
        "Description": "AZ for siggySubnetCidr",
        "Type": "AWS::EC2::AvailabilityZone::Name"
    }
  },
    "Mappings": {

    },
    "Conditions": {

    },
    "Resources": {
      "siggyVpc": {
      "Type": "AWS::EC2::VPC",
      "Properties": {
        "CidrBlock": { "Ref": "siggyVpcCidr" },
        "Tags": [{ "Key": "Name", "Value":  "siggyVpc" }]
      }
    },
    "siggyIgw": {
      "Type": "AWS::EC2::InternetGateway",
      "Properties": {
        "Tags": [{ "Key": "Name", "Value":  "siggyIgw1" }]
      }
    },
    "AttachGateway": {
      "Type": "AWS::EC2::VPCGatewayAttachment",
      "Properties": {
        "VpcId": { "Ref": "siggyVpc" },
        "InternetGatewayId": { "Ref": "siggyIgw" }
      }
    },
    "SubnetSiggy": {
      "Type": "AWS::EC2::Subnet",
      "Properties": {
        "AvailabilityZone": { "Ref": "Subnet1Az" },
        "VpcId": { "Ref": "siggyVpc" },
        "CidrBlock": { "Ref": "siggySubnetCidr" },
        "Tags": [{ "Key": "Name", "Value":  "siggySubnetCidr" }]
      }
    }
    },
    "Outputs": {

    }
}

I've been trying to figure out why my VPC and subnet show side by side instead of the subnet inside of the VPC? (I used Atom to generate this.)

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "vpc",
    "Metadata": {

    },
    "Parameters": {"siggyVpcCidr": {
        "Description": "vpc cidr",
        "Type": "String",
        "Default": "10.0.0.0/16"
    },
    "siggySubnetCidr": {
        "Description": "cidr for the subnet",
        "Type": "String",
        "Default": "10.0.1.0/2"
    },
    "Subnet1Az": {
        "Description": "AZ for siggySubnetCidr",
        "Type": "AWS::EC2::AvailabilityZone::Name"
    }
  },
    "Mappings": {

    },
    "Conditions": {

    },
    "Resources": {
      "siggyVpc": {
      "Type": "AWS::EC2::VPC",
      "Properties": {
        "CidrBlock": { "Ref": "siggyVpcCidr" },
        "Tags": [{ "Key": "Name", "Value":  "siggyVpc" }]
      }
    },
    "siggyIgw": {
      "Type": "AWS::EC2::InternetGateway",
      "Properties": {
        "Tags": [{ "Key": "Name", "Value":  "siggyIgw1" }]
      }
    },
    "AttachGateway": {
      "Type": "AWS::EC2::VPCGatewayAttachment",
      "Properties": {
        "VpcId": { "Ref": "siggyVpc" },
        "InternetGatewayId": { "Ref": "siggyIgw" }
      }
    },
    "SubnetSiggy": {
      "Type": "AWS::EC2::Subnet",
      "Properties": {
        "AvailabilityZone": { "Ref": "Subnet1Az" },
        "VpcId": { "Ref": "siggyVpc" },
        "CidrBlock": { "Ref": "siggySubnetCidr" },
        "Tags": [{ "Key": "Name", "Value":  "siggySubnetCidr" }]
      }
    }
    },
    "Outputs": {

    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橙幽之幻 2025-01-26 23:47:52

它们是独立的资源。云形式模板将资源安排在平坦的阵列中。大多数资源几乎都是如此。创建资源时可以隐式定义某些资源,但这可能不会反映在您从现有资源中创建模板的导出。

您需要检查VPCID属性以确定子网所属的VPC。

They are separate resources. CloudFormation templates arrange resources in a flat array. This is pretty much true of most resources. Some resources can be implicitly defined when creating resources, but that probably won't be reflected with an export where you create a template from existing resources.

You would need to inspect the VpcId property to determine the VPC to which the subnet belongs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文