ALIYUN::ECS::VSwitch is used to create a VSwitch.

Syntax

{
  "Type": "ALIYUN::ECS::VSwitch",
  "Properties": {
    "VSwitchName": String,
    "VpcId": String,
    "Description": String,
    "Tags": List,
    "Ipv6CidrBlock": Integer,
    "ZoneId": String,
    "CidrBlock": String
  }
}

Properties

Property Type Required Editable Description Constraint
VpcId String Yes No The ID of the VPC where the VSwitch is to be created. None
ZoneId String Yes No The ID of the zone. None
VSwitchName String No Yes The name of the VSwitch.
  • The name must be 2 to 128 characters in length.
  • The name must start with a letter and cannot start with http:// or https://.
  • The name can contain letters, digits, underscores (_), and hyphens (-).
CidrBlock String Yes No The CIDR block of the VSwitch. The VSwitch CIDR block must be a subset of the CIDR block assigned to the VPC where the VSwitch resides and cannot be in use by other VSwitches.
Description String No Yes The description of the VSwitch.
  • The description must be 2 to 256 characters in length.
  • It cannot start with http:// or https://.
Ipv6CidrBlock Integer No No The IPv6 CIDR block of the VSwitch. Valid values: 0 to 255. The value is a decimal integer.

By default, the prefix of the IPv6 CIDR block of the VSwitch is set to /64.

You can customize the last eight bits of the IPv6 CIDR block.

Tags List No No The tag of the VSwitch. Example: [{"Key": "VswTag", "Value": ""}]. A maximum of 20 tags can be specified. Each tag is a key-value pair. The tag value can be left empty.

Response parameters

Fn::GetAtt

  • VSwitchId: the VSwitch ID allocated by the system.
  • CidrBlock: the IPv4 CIDR block of the VSwitch.
  • Ipv6CidrBlock: the IPv6 CIDR block of the VSwitch.

Examples

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "VpcName": {
      "Type": "String"
    },
    "VSwitch1CidrBlock": {
      "Type": "String",
      "Default": "172.16.100.0/24"
    },
    "VSwitch2CidrBlock": {
        "Type": "String",
        "Default": "172.16.80.0/24"
    }
  },
  "Resources": {
    "EcsVpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "CidrBlock": "172.16.0.0/12",
        "VpcName": {"Ref": "VpcName"},
      },
    },
    "VSwitch1": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "ZoneId": "cn-beijing-a",
        "CidrBlock": {"Ref": "VSwitch1CidrBlock"},
        "VpcId": { "Fn::GetAtt": [ "EcsVpc", "VpcId" ] },
        "VSwitchName": "create_vpc_vswitch_sg1"
      }
    },
    "VSwitch2": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "ZoneId": "cn-beijing-a",
        "CidrBlock": {"Ref": "VSwitch2CidrBlock"},
        "VpcId": { "Fn::GetAtt": [ "EcsVpc", "VpcId" ] },
        "VSwitchName": "create_vpc_vswitch_sg2"
      }
    },
    "SG_VSwitch1": {
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Properties": {
        "SecurityGroupName": "app_mall",
        "Description": "this is created by heat",
        "VpcId": { "Fn::GetAtt": [ "EcsVpc", "VpcId" ] }
      },
      "Outputs": {
        "SecurityGroupId": {
             "Value": {"get_attr": ["SG_VSwitch1","SecurityGroupId"]}
        }
      }
    },
    "SG_VSwitch1_InRule": {
      "Type": "ALIYUN::ECS::SecurityGroupIngress",
      "Properties": {
        "SecurityGroupId": { "Fn::GetAtt": [ "SG_VSwitch1", "SecurityGroupId" ] },
        "IpProtocol": "tcp",
        "PortRange": "1/65535",
        "SourceCidrIp": {"Ref": "VSwitch2CidrBlock"}
      }
    },
    "SG_VSwitch1_OutRule": {
      "Type": "ALIYUN::ECS::SecurityGroupEgress",
      "Properties": {
        "SecurityGroupId": { "Fn::GetAtt": [ "SG_VSwitch1", "SecurityGroupId" ] },
        "IpProtocol": "tcp",
        "PortRange": "1/65535",
        "DestCidrIp": {"Ref": "VSwitch2CidrBlock"}
      }
    },
    "SG_VSwitch2": {
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Properties": {
        "SecurityGroupName": "app_mall",
        "Description": "this is created by heat",
        "VpcId": { "Fn::GetAtt": [ "EcsVpc", "VpcId" ] }
      },
    },
    "SG_VSwitch2_InRule": {
      "Type": "ALIYUN::ECS::SecurityGroupIngress",
      "Properties": {
        "SecurityGroupId": { "Fn::GetAtt": [ "SG_VSwitch2", "SecurityGroupId" ] },
        "IpProtocol": "tcp",
        "PortRange": "1/65535",
        "SourceCidrIp": {"Ref": "VSwitch1CidrBlock"}
      }
    },
    "SG_VSwitch2_OutRule": {
      "Type": "ALIYUN::ECS::SecurityGroupEgress",
      "Properties": {
        "SecurityGroupId": { "Fn::GetAtt": [ "SG_VSwitch2", "SecurityGroupId" ] },
        "IpProtocol": "tcp",
        "PortRange": "1/65535",
        "DestCidrIp": {"Ref": "VSwitch1CidrBlock"}
      }
    }
  }
}