Todos os produtos
Search
Central de documentação

Resource Orchestration Service:ALIYUN::ECS::VPC

Última atualização: Jun 27, 2026

Use ALIYUN::ECS::VPC para criar uma Virtual Private Cloud (VPC).

Sintaxe

{
  "Type": "ALIYUN::ECS::VPC",
  "Properties": {
    "Description": String,
    "Tags": List,
    "Ipv6CidrBlock": String,
    "EnableIpv6": Boolean,
    "ResourceGroupId": String,
    "VpcName": String,
    "CidrBlock": String,
    "Ipv6Isp": String,
    "UserCidr": String,
    "SecondaryCidrBlocks": List
  }
}

Propriedades

Nome da propriedade

Tipo

Obrigatório

Atualização permitida

Descrição

Restrições

ResourceGroupId

String

Não

Sim

ID do grupo de recursos.

Nenhuma

VpcName

String

Não

Sim

Nome da VPC.

O valor deve ter de 2 a 128 caracteres. Deve começar com uma letra ou caractere chinês, mas não pode iniciar com http:// ou https://. Pode conter letras, caracteres chineses, dígitos, sublinhados (_) e hifens (-).

CidrBlock

String

Não

Sim

Bloco CIDR IPv4 da VPC.

Valores válidos:

  • 10.0.0.0/8

  • 172.16.0.0/12

  • 192.168.0.0/16 e suas sub-redes

Description

String

Não

Sim

Descrição da VPC.

A descrição deve ter de 2 a 256 caracteres. Não pode começar com http:// ou https://.

Ipv6CidrBlock

String

Não

Não

Bloco CIDR IPv6 da VPC.

Nenhuma

EnableIpv6

Boolean

Não

Sim

Define se o IPv6 deve ser ativado para a VPC.

Valores válidos:

  • true: recurso ativado.

  • false (padrão): desativado.

Tags

List

Não

Sim

Tag

Adicione até 20 tags.

Para mais informações, consulte Propriedades de Tags.

Ipv6Isp

String

Não

Não

Tipo de segmento de endereço IPv6 da Virtual Private Cloud (VPC).

Valores válidos:

  • BGP (padrão): IPv6 do Border Gateway Protocol (BGP) da Alibaba Cloud

UserCidr

String

Não

Não

Bloco CIDR do usuário.

Para especificar vários blocos CIDR, separe-os por vírgulas (,). O limite máximo é de três blocos CIDR.

Nota

Para mais informações sobre blocos CIDR de usuário, consulte Perguntas frequentes sobre blocos CIDR.

SecondaryCidrBlocks

List

Não

Não

SecondaryCidrBlocks

Nenhuma

Sintaxe de Tags

"Tags": [
  {
    "Value": String,
    "Key": String
  }
]  

Propriedades de Tags

Nome da propriedade

Tipo

Obrigatório

Atualização permitida

Descrição

Restrições

Key

String

Sim

Não

Chave da tag.

A chave deve ter de 1 a 128 caracteres. Não pode começar com aliyun ou acs:. Não pode conter http:// ou https://.

Value

String

Não

Não

Valor da tag.

O valor deve ter de 0 a 128 caracteres. Não pode começar com aliyun ou acs:. Não pode conter http:// ou https://.

Valores de retorno

Fn::GetAtt

  • VpcId: ID da VPC.

  • VRouterId: ID do vRouter.

  • RouteTableId: ID da tabela de rotas.

  • VpcName: nome da VPC.

Exemplos

Cenário 1: Criar uma VPC

Criação rápida

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  VpcCidrBlock:
    Type: String
    Label: VPC IPv4 CIDR block
    Description: 'The IP address range of the VPC in CIDR block format.<br>You can use the following IP address ranges and their subnets:<br><font color=''green''>[10.0.0.0/8]</font><br><font color=''green''>[172.16.0.0/12]</font><br><font color=''green''>[192.168.0.0/16]</font>'
    Default: 192.168.0.0/16
    AssociationProperty: ALIYUN::VPC::VPC::CidrBlock
  VpcName:
    Type: String
    Label: VPC Name
    Description: The name of the VPC. It must be 2 to 128 characters in length, start with an uppercase or lowercase letter or a Chinese character, and can contain numbers, underscores (_), and hyphens (-).
    ConstraintDescription: 'The name must be 2 to 128 characters in length.'
    Default: MyVpc
    MinLength: 2
    MaxLength: 128
Resources:
  Vpc:
    Type: ALIYUN::ECS::VPC
    Properties:
      CidrBlock:
        Ref: VpcCidrBlock
      VpcName:
        Ref: VpcName
Outputs:
  VRouterId:
    Description: Router ID of the created VPC.
    Value:
      Fn::GetAtt:
        - Vpc
        - VRouterId
  RouteTableId:
    Description: The route table ID of the created VPC.
    Value:
      Fn::GetAtt:
        - Vpc
        - RouteTableId
  VpcId:
    Description: ID of the created VPC.
    Value:
      Fn::GetAtt:
        - Vpc
        - VpcId
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "VpcCidrBlock": {
      "Type": "String",
      "Label": {
        "en": "VPC CIDR IPv4 Block"
      },
      "Description": {
        "en": "The ip address range of the VPC in the CidrBlock form; <br>You can use the following ip address ranges and their subnets: <br><font color='green'>[10.0.0.0/8]</font><br><font color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font>"
      },
      "Default": "192.168.0.0/16",
      "AssociationProperty": "ALIYUN::VPC::VPC::CidrBlock"
    },
    "VpcName": {
      "Type": "String",
      "Label": {
        "en": "VPC Name"
      },
      "Description": {
        "en": "VPC name, 2 to 128 characters in length, beginning with size letters or Chinese characters, including Numbers, '_' or '-'.",
      },
      "ConstraintDescription": {
        "en": "[2, 128] English or Chinese characters"
      },
      "Default": "MyVpc",
      "MinLength": 2,
      "MaxLength": 128
    }
  },
  "Resources": {
    "Vpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "CidrBlock": {
          "Ref": "VpcCidrBlock"
        },
        "VpcName": {
          "Ref": "VpcName"
        }
      }
    }
  },
  "Outputs": {
    "VRouterId": {
      "Description": "Router id of created VPC.",
      "Value": {
        "Fn::GetAtt": [
          "Vpc",
          "VRouterId"
        ]
      }
    },
    "RouteTableId": {
      "Description": "The router table id of created VPC.",
      "Value": {
        "Fn::GetAtt": [
          "Vpc",
          "RouteTableId"
        ]
      }
    },
    "VpcId": {
      "Description": "Id of created VPC.",
      "Value": {
        "Fn::GetAtt": [
          "Vpc",
          "VpcId"
        ]
      }
    }
  }
}

Cenário 2: Criar uma instância ECS dual-stack (IPv4 e IPv6) e configurar um gateway IPv6 e largura de banda

Criação rápida

ROSTemplateFormatVersion: '2015-09-01'
Description:
  en: Create a dual-stack cloud server (ECS) and automatically configure IPv6 public IP, including VPC, security group, IPv6 gateway and bandwidth settings.
Parameters:
  InstanceImageId:
    AssociationPropertyMetadata:
      InstanceType: ${InstanceType}
      SupportedImageOwnerAlias:
        - system
        - self
        - others
    Description:
      en: 'The image ID.For Linux, select: <font color=''red''><b>centos_7</font> For Windows, select: <font color=''red''><b>win2008r2, win2012r2, or win2016</font>'
    Default: centos_7_04_64_20G_alibase_201701015.vhd
    Label:
      en: Image
    AssociationProperty: ALIYUN::ECS::Image::ImageId
    Type: String
  SystemDiskCategory:
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      LocaleKey: DiskCategory
      InstanceType: ${InstanceType}
    Type: String
    Description:
      en: '<font color=''blue''>Valid values:</font>[cloud_efficiency: <font color=''green''>ultra disk</font>]<br>[cloud_ssd: <font color=''green''>standard SSD</font>]<br>[cloud_essd: <font color=''green''>enterprise SSD</font>]<br>[cloud: <font color=''green''>basic disk</font>]<br>[ephemeral_ssd: <font color=''green''>local SSD</font>]'
    Label:
      en: System Disk Type
  SystemDiskSize:
    Default: 40
    Type: Number
    Description:
      en: 'The size of the system disk. Unit: GB. Valid values: 20 to 500.'
    Label:
      en: System Disk Space
  VpcCidrBlock:
    Default: 192.168.0.0/16
    Label:
      en: VPC IPv4 CIDR Block
    Type: String
    Description:
      en: 'The IPv4 CIDR block of the VPC. We recommend that you use one of the following CIDR blocks:<br><font color=''green''>[10.0.0.0/8]</font><br><font color=''green''>[172.16.0.0/12]</font><br><font color=''green''>[192.168.0.0/16]</font>'
    AllowedValues:
      - 192.168.0.0/16
      - 172.16.0.0/12
      - 10.0.0.0/8
  InstanceType:
    AssociationProperty: ALIYUN::ECS::Instance::InstanceType
    AssociationPropertyMetadata:
      ZoneId: VSwitchZoneId
    Type: String
    Description:
      en: 'The instance type. Make sure that the instance type is available in the selected zone.<br>A common instance type is <font color=''red''><b>ecs.c5.large</font>.Note: Some zones may not support all instance types.<br>For more information, see <a href=''https://www.alibabacloud.com/help/en/doc-detail/25378.html'' target=''_blank''><b><font color=''blue''>Instance families</font></a>.'
    Label:
      en: Instance Type
  InstancePassword:
    Description:
      en: 'The logon password of the ECS instance. The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/.'
    Type: String
    Label:
      en: Instance Password
    NoEcho: true
    AssociationProperty: ALIYUN::ECS::Instance::Password
    ConstraintDescription:
      en: 'The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;''<>,.?/.'
  VSwitchCidrBlock:
    Default: 192.168.0.0/24
    Type: String
    Description:
      en: The IPv4 CIDR block of the vSwitch. The CIDR block must be a subnet of the VPC.
    Label:
      en: vSwitch IPv4 CIDR Block
  InternetChargeType:
    Default: PayByBandwidth
    AssociationPropertyMetadata:
      LocaleKey: InternetChargeType
    Label:
      en: IPv6 Internet Bandwidth Billing Method
    Type: String
    AllowedValues:
      - PayByTraffic
      - PayByBandwidth
  IPV6Bandwidth:
    Default: 10
    Type: Number
    Description:
      en: 'The public bandwidth of the IPv6 gateway. Unit: Mbit/s. Valid values: 1 to 5000. If you set the billing method to pay-by-traffic, the value range is 1 to 2000. If you set the billing method to pay-by-bandwidth, the value range is 1 to 5000.'
    Label:
      en: IPv6 Gateway Public Bandwidth
  VSwitchZoneId:
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
    Type: String
    Description:
      en: 'The ID of the zone.<b>Note: <font color=''blue''>Before you select a zone, make sure that the zone supports the ECS resources that you want to create. We recommend that you select a zone that is different from the zones of other vSwitches.</font>'
    Label:
      en: vSwitch Zone
  InstancePublicIP:
    Default: false
    Type: Boolean
    Description:
      en: Specifies whether to assign a public IPv4 address.
    Label:
      en: Allocate Public IPv4 Address
  IPV6GateWaySpec:
    AssociationPropertyMetadata:
      LocaleKey: NatGatewaySpec
    Description:
      en: 'The edition of the IPv6 gateway. Valid values: Small (Free Edition), Medium (Enterprise Edition), and Large (Enterprise Enhanced Edition).'
    Default: Small
    Label:
      en: IPv6 Gateway Specification
    AllowedValues:
      - Small
      - Medium
      - Large
    Type: String
Outputs:
  EcsInstanceId:
    Description: EcsInstance InstanceId
    Value:
      Fn::GetAtt:
        - EcsInstance
        - InstanceId
  EcsInstancePrivateIp:
    Description: EcsInstance PrivateIp
    Value:
      Fn::GetAtt:
        - EcsInstance
        - PrivateIp
  EcsInstanceIpv6Address:
    Description: EcsInstance Ipv6Address
    Value:
      Fn::Select:
        - '0'
        - Fn::GetAtt:
            - EcsAssignIpv6Addresses
            - Ipv6Addresses
Conditions: {}
Resources:
  EcsSecurityGroup:
    Type: ALIYUN::ECS::SecurityGroup
    Properties:
      SecurityGroupIngress:
        - Priority: 1
          IpProtocol: tcp
          NicType: intranet
          SourceCidrIp: 0.0.0.0/0
          PortRange: 3389/3389
        - Priority: 1
          IpProtocol: all
          NicType: intranet
          Ipv6SourceCidrIp: '::/0'
          PortRange: '-1/-1'
      VpcId:
        Ref: EcsVpc
      SecurityGroupEgress:
        - Priority: 1
          IpProtocol: tcp
          DestCidrIp: 0.0.0.0/0
          NicType: intranet
          PortRange: 3389/3389
        - Ipv6DestCidrIp: '::/0'
          IpProtocol: all
          Priority: 1
          NicType: intranet
          PortRange: '-1/-1'
  WaitConditionHandle:
    Type: ALIYUN::ROS::WaitConditionHandle
    Properties: {}
  VpcIpv6InternetBandwidth:
    Type: ALIYUN::VPC::Ipv6InternetBandwidth
    Properties:
      InternetChargeType:
        Ref: InternetChargeType
      Bandwidth:
        Ref: IPV6Bandwidth
      Ipv6AddressId:
        Fn::Select:
          - 0
          - Fn::GetAtt:
              - EcsAssignIpv6Addresses
              - Ipv6AddressIds
      Ipv6GatewayId:
        Ref: VpcIpv6Gateway
    DependsOn:
      - EcsAssignIpv6Addresses
      - VpcIpv6Gateway
  VpcIpv6Gateway:
    Type: ALIYUN::VPC::Ipv6Gateway
    Properties:
      VpcId:
        Ref: EcsVpc
      Name: MyIpv6Gateway
      Spec:
        Ref: IPV6GateWaySpec
  EcsAssignIpv6Addresses:
    Type: ALIYUN::ECS::AssignIpv6Addresses
    Properties:
      NetworkInterfaceId:
        Fn::GetAtt:
          - EcsInstance
          - PrimaryNetworkInterfaceId
      Ipv6AddressCount: 1
    DependsOn:
      - EcsInstance
  EcsVSwitch:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      Ipv6CidrBlock: 0
      VpcId:
        Ref: EcsVpc
      CidrBlock:
        Ref: VSwitchCidrBlock
      ZoneId:
        Ref: VSwitchZoneId
  WaitCondition:
    Type: ALIYUN::ROS::WaitCondition
    Properties:
      Count: 1
      Handle:
        Ref: WaitConditionHandle
      Timeout: 900
  EcsInstance:
    Type: ALIYUN::ECS::Instance
    Properties:
      UserData:
        Fn::Replace:
          - ros-notify:
              Fn::GetAtt:
                - WaitConditionHandle
                - CurlCli
          - Fn::Join:
              - ''
              - - '#!/bin/sh'
                - |2
 
                - |
                  cd /opt 
                - |
                  wget http://ecs-image-utils.oss-cn-hangzhou.aliyuncs.com/ipv6/rhel/ecs-utils-ipv6 
                - |
                  chmod +x ./ecs-utils-ipv6 
                - |
                  ./ecs-utils-ipv6 
                - |
                  ros-notify -d "{\"Data\" : \"SUCCESS\", \"Status\" : \"SUCCESS\"}" 
      SystemDiskCategory:
        Ref: SystemDiskCategory
      VpcId:
        Ref: EcsVpc
      SecurityGroupId:
        Ref: EcsSecurityGroup
      SystemDiskSize:
        Ref: SystemDiskSize
      ImageId:
        Ref: InstanceImageId
      AllocatePublicIP:
        Ref: InstancePublicIP
      VSwitchId:
        Ref: EcsVSwitch
      IoOptimized: optimized
      Password:
        Ref: InstancePassword
      InstanceType:
        Ref: InstanceType
    DependsOn:
      - EcsSecurityGroup
      - EcsVSwitch
      - EcsVpc
  EcsVpc:
    Type: ALIYUN::ECS::VPC
    Properties:
      CidrBlock:
        Ref: VpcCidrBlock
      VpcName:
        Fn::Join:
          - '-'
          - - StackId
            - Ref: ALIYUN::StackId
      EnableIpv6: true
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - VpcCidrBlock
          - VSwitchCidrBlock
          - VSwitchZoneId
          - InstanceType
          - InstanceImageId
          - SystemDiskSize
          - InstancePublicIP
          - InternetChargeType
          - IPV6Bandwidth
          - IPV6GateWaySpec
          - SystemDiskCategory
          - InstancePassword
        Label:
          default: ECS
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "en": "Create a dual-stack cloud server (ECS) and automatically configure IPv6 public IP, including VPC, security group, IPv6 gateway and bandwidth settings."
  },
  "Parameters": {
    "InstanceImageId": {
      "AssociationPropertyMetadata": {
        "InstanceType": "${InstanceType}",
        "SupportedImageOwnerAlias": [
          "system",
          "self",
          "others"
        ]
      },
      "Description": {
        "en": "The image ID.For Linux, select: <font color='red'><b>centos_7</font> For Windows, select: <font color='red'><b>win2008r2, win2012r2, or win2016</font>"
      },
      "Default": "centos_7_04_64_20G_alibase_201701015.vhd",
      "Label": {
        "en": "Image"
      },
      "AssociationProperty": "ALIYUN::ECS::Image::ImageId",
      "Type": "String"
    },
    "SystemDiskCategory": {
      "AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
      "AssociationPropertyMetadata": {
        "LocaleKey": "DiskCategory",
        "InstanceType": "${InstanceType}"
      },
      "Type": "String",
      "Description": {
        "en": "<font color='blue'>Valid values:</font>[cloud_efficiency: <font color='green'>ultra disk</font>]<br>[cloud_ssd: <font color='green'>standard SSD</font>]<br>[cloud_essd: <font color='green'>enterprise SSD</font>]<br>[cloud: <font color='green'>basic disk</font>]<br>[ephemeral_ssd: <font color='green'>local SSD</font>]"
      },
      "Label": {
        "en": "System Disk Type"
      }
    },
    "SystemDiskSize": {
      "Default": 40,
      "Type": "Number",
      "Description": {
        "en": "The size of the system disk. Unit: GB. Valid values: 20 to 500."
      },
      "Label": {
        "en": "System Disk Space"
      }
    },
    "VpcCidrBlock": {
      "Default": "192.168.0.0/16",
      "Label": {
        "en": "VPC IPv4 CIDR Block"
      },
      "Type": "String",
      "Description": {
        "en": "The IPv4 CIDR block of the VPC. We recommend that you use one of the following CIDR blocks:<br><font color='green'>[10.0.0.0/8]</font><br><font color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font>"
      },
      "AllowedValues": [
        "192.168.0.0/16",
        "172.16.0.0/12",
        "10.0.0.0/8"
      ]
    },
    "InstanceType": {
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "ZoneId": "VSwitchZoneId"
      },
      "Type": "String",
      "Description": {
        "en": "The instance type. Make sure that the instance type is available in the selected zone.<br>A common instance type is <font color='red'><b>ecs.c5.large</font>.Note: Some zones may not support all instance types.<br>For more information, see <a href='https://www.alibabacloud.com/help/en/doc-detail/25378.html' target='_blank'><b><font color='blue'>Instance families</font></a>."
      },
      "Label": {
        "en": "Instance Type"
      }
    },
    "InstancePassword": {
      "Description": {
        "en": "The logon password of the ECS instance. The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/."
      },
      "Type": "String",
      "Label": {
        "en": "Instance Password"
      },
      "NoEcho": true,
      "AssociationProperty": "ALIYUN::ECS::Instance::Password",
      "ConstraintDescription": {
        "en": "The password must be 8 to 30 characters in length and contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/."
      }
    },
    "VSwitchCidrBlock": {
      "Default": "192.168.0.0/24",
      "Type": "String",
      "Description": {
        "en": "The IPv4 CIDR block of the vSwitch. The CIDR block must be a subnet of the VPC."
      },
      "Label": {
        "en": "vSwitch IPv4 CIDR Block"
      }
    },
    "InternetChargeType": {
      "Default": "PayByBandwidth",
      "AssociationPropertyMetadata": {
        "LocaleKey": "InternetChargeType"
      },
      "Label": {
        "en": "IPv6 Internet Bandwidth Billing Method"
      },
      "Type": "String",
      "AllowedValues": [
        "PayByTraffic",
        "PayByBandwidth"
      ]
    },
    "IPV6Bandwidth": {
      "Default": 10,
      "Type": "Number",
      "Description": {
        "en": "The public bandwidth of the IPv6 gateway. Unit: Mbit/s. Valid values: 1 to 5000. If you set the billing method to pay-by-traffic, the value range is 1 to 2000. If you set the billing method to pay-by-bandwidth, the value range is 1 to 5000."
      },
      "Label": {
        "en": "IPv6 Gateway Public Bandwidth"
      }
    },
    "VSwitchZoneId": {
      "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId",
      "Type": "String",
      "Description": {
        "en": "The ID of the zone.<b>Note: <font color='blue'>Before you select a zone, make sure that the zone supports the ECS resources that you want to create. We recommend that you select a zone that is different from the zones of other vSwitches.</font>"
      },
      "Label": {
        "en": "vSwitch Zone"
      }
    },
    "InstancePublicIP": {
      "Default": false,
      "Type": "Boolean",
      "Description": {
        "en": "Specifies whether to assign a public IPv4 address."
      },
      "Label": {
        "en": "Allocate Public IPv4 Address"
      }
    },
    "IPV6GateWaySpec": {
      "AssociationPropertyMetadata": {
        "LocaleKey": "NatGatewaySpec"
      },
      "Description": {
        "en": "The edition of the IPv6 gateway. Valid values: Small (Free Edition), Medium (Enterprise Edition), and Large (Enterprise Enhanced Edition)."
      },
      "Default": "Small",
      "Label": {
        "en": "IPv6 Gateway Specification"
      },
      "AllowedValues": [
        "Small",
        "Medium",
        "Large"
      ],
      "Type": "String"
    }
  },
  "Outputs": {
    "EcsInstanceId": {
      "Description": "EcsInstance InstanceId",
      "Value": {
        "Fn::GetAtt": [
          "EcsInstance",
          "InstanceId"
        ]
      }
    },
    "EcsInstancePrivateIp": {
      "Description": "EcsInstance PrivateIp",
      "Value": {
        "Fn::GetAtt": [
          "EcsInstance",
          "PrivateIp"
        ]
      }
    },
    "EcsInstanceIpv6Address": {
      "Description": "EcsInstance Ipv6Address",
      "Value": {
        "Fn::Select": [
          "0",
          {
            "Fn::GetAtt": [
              "EcsAssignIpv6Addresses",
              "Ipv6Addresses"
            ]
          }
        ]
      }
    }
  },
  "Conditions": {},
  "Resources": {
    "EcsSecurityGroup": {
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Properties": {
        "SecurityGroupIngress": [
          {
            "Priority": 1,
            "IpProtocol": "tcp",
            "NicType": "intranet",
            "SourceCidrIp": "0.0.0.0/0",
            "PortRange": "3389/3389"
          },
          {
            "Priority": 1,
            "IpProtocol": "all",
            "NicType": "intranet",
            "Ipv6SourceCidrIp": "::/0",
            "PortRange": "-1/-1"
          }
        ],
        "VpcId": {
          "Ref": "EcsVpc"
        },
        "SecurityGroupEgress": [
          {
            "Priority": 1,
            "IpProtocol": "tcp",
            "DestCidrIp": "0.0.0.0/0",
            "NicType": "intranet",
            "PortRange": "3389/3389"
          },
          {
            "Ipv6DestCidrIp": "::/0",
            "IpProtocol": "all",
            "Priority": 1,
            "NicType": "intranet",
            "PortRange": "-1/-1"
          }
        ]
      }
    },
    "WaitConditionHandle": {
      "Type": "ALIYUN::ROS::WaitConditionHandle",
      "Properties": {}
    },
    "VpcIpv6InternetBandwidth": {
      "Type": "ALIYUN::VPC::Ipv6InternetBandwidth",
      "Properties": {
        "InternetChargeType": {
          "Ref": "InternetChargeType"
        },
        "Bandwidth": {
          "Ref": "IPV6Bandwidth"
        },
        "Ipv6AddressId": {
          "Fn::Select": [
            0,
            {
              "Fn::GetAtt": [
                "EcsAssignIpv6Addresses",
                "Ipv6AddressIds"
              ]
            }
          ]
        },
        "Ipv6GatewayId": {
          "Ref": "VpcIpv6Gateway"
        }
      },
      "DependsOn": [
        "EcsAssignIpv6Addresses",
        "VpcIpv6Gateway"
      ]
    },
    "VpcIpv6Gateway": {
      "Type": "ALIYUN::VPC::Ipv6Gateway",
      "Properties": {
        "VpcId": {
          "Ref": "EcsVpc"
        },
        "Name": "MyIpv6Gateway",
        "Spec": {
          "Ref": "IPV6GateWaySpec"
        }
      }
    },
    "EcsAssignIpv6Addresses": {
      "Type": "ALIYUN::ECS::AssignIpv6Addresses",
      "Properties": {
        "NetworkInterfaceId": {
          "Fn::GetAtt": [
            "EcsInstance",
            "PrimaryNetworkInterfaceId"
          ]
        },
        "Ipv6AddressCount": 1
      },
      "DependsOn": [
        "EcsInstance"
      ]
    },
    "EcsVSwitch": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "Ipv6CidrBlock": 0,
        "VpcId": {
          "Ref": "EcsVpc"
        },
        "CidrBlock": {
          "Ref": "VSwitchCidrBlock"
        },
        "ZoneId": {
          "Ref": "VSwitchZoneId"
        }
      }
    },
    "WaitCondition": {
      "Type": "ALIYUN::ROS::WaitCondition",
      "Properties": {
        "Count": 1,
        "Handle": {
          "Ref": "WaitConditionHandle"
        },
        "Timeout": 900
      }
    },
    "EcsInstance": {
      "Type": "ALIYUN::ECS::Instance",
      "Properties": {
        "UserData": {
          "Fn::Replace": [
            {
              "ros-notify": {
                "Fn::GetAtt": [
                  "WaitConditionHandle",
                  "CurlCli"
                ]
              }
            },
            {
              "Fn::Join": [
                "",
                [
                  "#!/bin/sh",
                  " \n",
                  "cd /opt \n",
                  "wget http://ecs-image-utils.oss-cn-hangzhou.aliyuncs.com/ipv6/rhel/ecs-utils-ipv6 \n",
                  "chmod +x ./ecs-utils-ipv6 \n",
                  "./ecs-utils-ipv6 \n",
                  "ros-notify -d \"{\\\"Data\\\" : \\\"SUCCESS\\\", \\\"Status\\\" : \\\"SUCCESS\\\"}\" \n"
                ]
              ]
            }
          ]
        },
        "SystemDiskCategory": {
          "Ref": "SystemDiskCategory"
        },
        "VpcId": {
          "Ref": "EcsVpc"
        },
        "SecurityGroupId": {
          "Ref": "EcsSecurityGroup"
        },
        "SystemDiskSize": {
          "Ref": "SystemDiskSize"
        },
        "ImageId": {
          "Ref": "InstanceImageId"
        },
        "AllocatePublicIP": {
          "Ref": "InstancePublicIP"
        },
        "VSwitchId": {
          "Ref": "EcsVSwitch"
        },
        "IoOptimized": "optimized",
        "Password": {
          "Ref": "InstancePassword"
        },
        "InstanceType": {
          "Ref": "InstanceType"
        }
      },
      "DependsOn": [
        "EcsSecurityGroup",
        "EcsVSwitch",
        "EcsVpc"
      ]
    },
    "EcsVpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "CidrBlock": {
          "Ref": "VpcCidrBlock"
        },
        "VpcName": {
          "Fn::Join": [
            "-",
            [
              "StackId",
              {
                "Ref": "ALIYUN::StackId"
              }
            ]
          ]
        },
        "EnableIpv6": true
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "VpcCidrBlock",
            "VSwitchCidrBlock",
            "VSwitchZoneId",
            "InstanceType",
            "InstanceImageId",
            "SystemDiskSize",
            "InstancePublicIP",
            "InternetChargeType",
            "IPV6Bandwidth",
            "IPV6GateWaySpec",
            "SystemDiskCategory",
            "InstancePassword"
          ],
          "Label": {
            "default": "ECS"
          }
        }
      ]
    }
  }
}

Cenário 3: Criar uma instância de Classic Load Balancer (CLB) do tipo VPC

Criação rápida

ROSTemplateFormatVersion: '2015-09-01'
Description:
  en: Creates a VPC and a vSwitch, and configures an internal-facing Server Load Balancer (SLB) instance. You can specify the instance type and address type.
Parameters:
  VpcCidrBlock:
    Type: String
    Label:
      en: VPC CIDR Block
    Description:
      en: 'The IPv4 CIDR block of the VPC. You can use the following CIDR blocks or their subnets: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16.'
    Default: 192.168.0.0/16
    AllowedValues:
      - 192.168.0.0/16
      - 172.16.0.0/12
      - 10.0.0.0/8
  VSwitchZoneId:
    Type: String
    Label:
      en: Zone ID
    Default: Null
    Description:
      en: The ID of the zone. Make sure that the zone supports SLB.
    AssociationProperty: ALIYUN::ECS::Instance::ZoneId
  VSwitchCidrBlock:
    Type: String
    Label:
      en: vSwitch CIDR Block
    Description:
      en: The CIDR block of the vSwitch. It must be a subnet of the VPC and cannot be in use by another vSwitch.
    Default: 192.168.0.0/24
  LoadBalancerSpec:
    Type: String
    Label:
      en: Specification
    Description:
      en: 'The specification of the SLB instance. For more information, see <a href=''https://www.alibabacloud.com/help/document_detail/85939.html'' target=''_blank''><font color=''blue''>SLB instance specifications</font>.</a>'
    Default: slb.s1.small
Conditions: {}
Resources:
  EcsVpc:
    Type: ALIYUN::ECS::VPC
    Properties:
      CidrBlock:
        Ref: VpcCidrBlock
      VpcName:
        Fn::Join:
          - '-'
          - - StackId
            - Ref: ALIYUN::StackId
  EcsVSwitch:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      ZoneId:
        Ref: VSwitchZoneId
      VpcId:
        Ref: EcsVpc
      CidrBlock:
        Ref: VSwitchCidrBlock
      VSwitchName:
        Fn::Join:
          - '-'
          - - StackId
            - Ref: ALIYUN::StackId
  SlbLoadBalancer:
    Type: ALIYUN::SLB::LoadBalancer
    Properties:
      VpcId:
        Ref: EcsVpc
      VSwitchId:
        Ref: EcsVSwitch
      AddressType: intranet
      LoadBalancerName:
        Fn::Join:
          - '-'
          - - StackId
            - Ref: ALIYUN::StackId
      LoadBalancerSpec:
        Ref: LoadBalancerSpec
      PayType: PayOnDemand
    DependsOn: EcsVSwitch
Outputs:
  SlbLoadBalancerId:
    Description:
      en: The ID of the SLB instance.
    Value:
      Fn::GetAtt:
        - SlbLoadBalancer
        - LoadBalancerId
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - VpcCidrBlock
          - VSwitchZoneId
          - VSwitchCidrBlock
        Label:
          default:
            en: VPC
      - Parameters:
          - LoadBalancerSpec
        Label:
          default:
            en: SLB
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "en": "Creates a VPC and a vSwitch, and configures an internal-facing Server Load Balancer (SLB) instance. You can specify the instance type and address type."
  },
  "Parameters": {
    "VpcCidrBlock": {
      "Type": "String",
      "Label": {
        "en": "VPC CIDR Block"
      },
      "Description": {
        "en": "The IPv4 CIDR block of the VPC. You can use the following CIDR blocks or their subnets: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16."
      },
      "Default": "192.168.0.0/16",
      "AllowedValues": [
        "192.168.0.0/16",
        "172.16.0.0/12",
        "10.0.0.0/8"
      ]
    },
    "VSwitchZoneId": {
      "Type": "String",
      "Label": {
        "en": "Zone ID"
      },
      "Default": null,
      "Description": {
        "en": "The ID of the zone. Make sure that the zone supports SLB."
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId"
    },
    "VSwitchCidrBlock": {
      "Type": "String",
      "Label": {
        "en": "vSwitch CIDR Block"
      },
      "Description": {
        "en": "The CIDR block of the vSwitch. It must be a subnet of the VPC and cannot be in use by another vSwitch."
      },
      "Default": "192.168.0.0/24"
    },
    "LoadBalancerSpec": {
      "Type": "String",
      "Label": {
        "en": "Specification"
      },
      "Description": {
        "en": "The specification of the SLB instance. For more information, see <a href='https://www.alibabacloud.com/help/document_detail/85939.html' target='_blank'><font color='blue'>SLB instance specifications</font>.</a>"
      },
      "Default": "slb.s1.small"
    }
  },
  "Conditions": {},
  "Resources": {
    "EcsVpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "CidrBlock": {
          "Ref": "VpcCidrBlock"
        },
        "VpcName": {
          "Fn::Join": [
            "-",
            [
              "StackId",
              {
                "Ref": "ALIYUN::StackId"
              }
            ]
          ]
        }
      }
    },
    "EcsVSwitch": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "ZoneId": {
          "Ref": "VSwitchZoneId"
        },
        "VpcId": {
          "Ref": "EcsVpc"
        },
        "CidrBlock": {
          "Ref": "VSwitchCidrBlock"
        },
        "VSwitchName": {
          "Fn::Join": [
            "-",
            [
              "StackId",
              {
                "Ref": "ALIYUN::StackId"
              }
            ]
          ]
        }
      }
    },
    "SlbLoadBalancer": {
      "Type": "ALIYUN::SLB::LoadBalancer",
      "Properties": {
        "VpcId": {
          "Ref": "EcsVpc"
        },
        "VSwitchId": {
          "Ref": "EcsVSwitch"
        },
        "AddressType": "intranet",
        "LoadBalancerName": {
          "Fn::Join": [
            "-",
            [
              "StackId",
              {
                "Ref": "ALIYUN::StackId"
              }
            ]
          ]
        },
        "LoadBalancerSpec": {
          "Ref": "LoadBalancerSpec"
        },
        "PayType": "PayOnDemand"
      },
      "DependsOn": "EcsVSwitch"
    }
  },
  "Outputs": {
    "SlbLoadBalancerId": {
      "Description": {
        "en": "The ID of the SLB instance."
      },
      "Value": {
        "Fn::GetAtt": [
          "SlbLoadBalancer",
          "LoadBalancerId"
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "VpcCidrBlock",
            "VSwitchZoneId",
            "VSwitchCidrBlock"
          ],
          "Label": {
            "default": {
              "en": "VPC"
            }
          }
        },
        {
          "Parameters": [
            "LoadBalancerSpec"
          ],
          "Label": {
            "default": {
              "en": "SLB"
            }
          }
        }
      ]
    }
  }
}

Para mais exemplos, consulte modelos públicos que contêm este recurso.