如何实现选择多个可用区的子网?

本文为您介绍如何实现选择多个可用区的子网。

如果您想在VPC下创建多个可用区的vSwitch,您可以在Parameters中定义多个可用区参数,例如ZoneId1、ZoneId2、ZoneId3,然后在Resources中分别定义vSwitch1、vSwitch2、vSwitch3并关联对应的可用区ZoneId。

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  ZoneId1:
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
    Type: String
    Label: 交换机可用区1
  ZoneId2:
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
    Type: String
    Label: 交换机可用区2
  ZoneId3:
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
    Type: String
    Label: 交换机可用区3
Resources:
  Vpc:
    Type: ALIYUN::ECS::VPC
    Properties:
      CidrBlock: 10.0.0.0/8
      VpcName: test-resource-count
  VSwitch1:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      CidrBlock: 10.0.10.0/24
      ZoneId:
        Ref: ZoneId1
      VpcId:
        Ref: Vpc
  VSwitch2:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      CidrBlock: 10.0.20.0/24
      ZoneId:
        Ref: ZoneId2
      VpcId:
        Ref: Vpc
  VSwitch3:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      CidrBlock: 10.0.30.0/24
      ZoneId:
        Ref: ZoneId3
      VpcId:
        Ref: Vpc

控制台示例

image