Tous les produits
Search
Centre de documentation

Resource Orchestration Service:ALIYUN::VPC::NatGateway

Dernière mise à jour :Aug 12, 2026

Crée une passerelle NAT dans un VPC spécifié.

Syntaxe

{
  "Type": "ALIYUN::VPC::NatGateway",
  "Properties": {
    "Description": String,
    "NatGatewayName": String,
    "InstanceChargeType": String,
    "VSwitchId": String,
    "DeletionProtection": Boolean,
    "InternetChargeType": String,
    "NatType": String,
    "DeletionForce": Boolean,
    "VpcId": String,
    "Tags": List,
    "NetworkType": String,
    "EipBindMode": String,
    "IcmpReplyEnabled": Boolean,
    "SecurityProtectionEnabled": Boolean,
    "Ipv4Prefix": String,
    "AvailabilityMode": String,
    "PrivateLinkEnabled": Boolean,
    "AccessMode": Map,
    "NatIp": String
  }
}

Propriétés

Nom de la propriété

Type

Obligatoire

Modifiable

Description

Contrainte

VpcId

String

Oui

Non

ID du VPC de la passerelle NAT.

Pour créer une passerelle NAT standard, vérifiez que la table de routage du VPC ne contient aucune entrée dont le bloc CIDR de destination est 0.0.0.0/0. Le cas échéant, supprimez-la au préalable.

Remarque

Cette restriction ne s'applique pas aux passerelles NAT améliorées.

VSwitchId

String

Oui

Non

ID du vSwitch de la passerelle NAT.

La création d'une passerelle NAT améliorée requiert un vSwitch. Le système lui attribue alors une adresse IP privée disponible dans ce vSwitch.

  • Pour créer une passerelle NAT améliorée dans un vSwitch existant, assurez-vous que sa zone prend en charge les passerelles NAT améliorées et qu'il dispose d'adresses IP libres.

  • En l'absence de vSwitch, créez-en un dans une zone compatible avec les passerelles NAT améliorées, puis associez-le à la passerelle.

Appelez l'opération ListEnhanhcedNatGatewayAvailableZones pour obtenir la liste des zones prenant en charge les passerelles NAT améliorées. L'opération DescribeVSwitches permet quant à elle de connaître le nombre d'adresses IP disponibles dans un vSwitch.

AccessMode

Map

Non

Non

Mode d'accès pour les connexions inverses vers la passerelle NAT.

Pour plus d'informations, consultez la section Propriétés AccessMode.

AvailabilityMode

String

Non

Non

Mode de disponibilité de la passerelle NAT.

Valeurs valides :

  • CrossAZ : déploiement multizone de la passerelle NAT.

  • SingleAZ : déploiement monozone de la passerelle NAT.

DeletionForce

Boolean

Non

Non

Indique si la suppression forcée de la passerelle NAT est activée.

Valeurs valides :

  • true : force la suppression.

  • false : n'impose pas la suppression forcée.

DeletionProtection

Boolean

Non

Oui

Active ou désactive la protection contre la suppression.

Valeurs valides :

  • true : active la protection contre la suppression.

  • false : désactive la protection contre la suppression.

Description

String

Non

Non

Description de la passerelle NAT.

La description doit comporter entre 2 et 256 caractères. Elle ne peut commencer ni par http://, ni par https://.

EipBindMode

String

Non

Non

Mode de liaison des EIP à la passerelle NAT.

Valeurs valides :

  • MULTI_BINDED (par défaut) : mode multi-EIP-vers-ENI.

  • NAT : mode NAT pour les EIP, compatible avec une passerelle IPv4.

    En mode NAT, vous pouvez lier jusqu'à 50 EIP à la passerelle NAT. Chaque EIP liée consomme une adresse IP privée du vSwitch hébergeant la passerelle.

    Remarque

    Si aucune adresse IP privée n'est disponible dans le vSwitch, la passerelle NAT ne peut accepter de nouvelles liaisons d'EIP.

IcmpReplyEnabled

Boolean

Non

Non

Indique si les réponses echo ICMP sont désactivées.

Valeurs valides :

  • true : désactive les réponses echo ICMP.

  • false (par défaut) : désactive la fonctionnalité de non-réponse ICMP.

InstanceChargeType

String

Non

Non

Mode de facturation de la passerelle NAT.

Valeurs valides :

  • PostPaid (par défaut) : paiement à l'utilisation.

  • Prepaid : abonnement.

InternetChargeType

String

Non

Non

Mode de comptage de la passerelle NAT.

Définissez cette valeur sur PayByLcu pour une facturation par unité de capacité (LCU).

Ipv4Prefix

String

Non

Non

Préfixe IPv4 servant à allouer les adresses IP NAT.

Utilisez ce paramètre pour créer plusieurs adresses IP NAT simultanément. Spécifiez un bloc CIDR réservé inutilisé par le vSwitch de la passerelle NAT.

NatGatewayName

String

Non

Non

Nom de la passerelle NAT.

Le nom doit comporter entre 2 et 128 caractères. Il doit commencer par une lettre ou un caractère chinois. Il ne peut commencer ni par http://, ni par https://. Il peut contenir des lettres, des caractères chinois, des chiffres, des points (.), des traits de soulignement (_) et des tirets (-).

À défaut, le système utilise l'ID de la passerelle NAT comme nom.

NatIp

String

Non

Non

Adresse IP NAT.

Aucune.

NatType

String

Non

Non

Type de la passerelle NAT.

Définissez cette valeur sur Enhanced pour créer une passerelle NAT améliorée.

NetworkType

String

Non

Non

Type de réseau de la passerelle NAT.

Valeurs valides :

  • internet (par défaut) : passerelle NAT Internet.

  • intranet : passerelle NAT intranet.

PrivateLinkEnabled

Boolean

Non

Non

Active ou désactive PrivateLink pour la passerelle NAT.

Valeurs valides :

  • true : active PrivateLink.

  • false : désactive PrivateLink.

SecurityProtectionEnabled

Boolean

Non

Non

Active ou désactive la fonctionnalité de pare-feu.

Valeurs valides :

  • true : active la fonctionnalité de pare-feu.

  • false (par défaut) : désactive la fonctionnalité de pare-feu.

Tags

List

Non

Oui

Tags

Vous pouvez attacher jusqu'à 20 tags.

Pour plus d'informations, consultez les sections Syntaxe des tags et Propriétés des tags.

Syntaxe AccessMode

"AccessMode": 
  {
    "TunnelType": String,
    "ModeValue": String
  }

Propriétés AccessMode

Paramètre

Type

Obligatoire

Modification autorisée

Description

Contraintes

ModeValue

String

false

false

Mode d'accès.

Valeurs valides :

  • route : mode routage

  • tunnel : mode tunnel

TunnelType

String

false

false

Type de tunnel.

Valeurs valides :

  • geneve : type Geneve

Syntaxe des tags

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

Propriétés des tags

Nom de la propriété

Type

Obligatoire

Modification autorisée

Description

Contrainte

Key

String

Oui

Non

Clé du tag.

La clé doit comporter entre 1 et 64 caractères. Elle doit commencer par une lettre ou un caractère chinois. Elle ne peut commencer ni par aliyun, ni par acs:. Elle ne peut contenir ni http://, ni https://. Elle peut contenir des lettres, des caractères chinois, des chiffres, des points (.), des traits de soulignement (_) et des tirets (-).

Value

String

Non

Non

Valeur du tag.

La valeur peut comporter entre 0 et 128 caractères. Elle doit commencer par une lettre ou un caractère chinois. Elle ne peut commencer ni par aliyun, ni par acs:. Elle ne peut contenir ni http://, ni https://. Elle peut contenir des lettres, des caractères chinois, des chiffres, des points (.), des traits de soulignement (_) et des tirets (-).

Valeurs de retour

Fn::GetAtt

  • NatGatewayId : ID de la passerelle NAT.

  • SNatTableId : ID de l'entrée SNAT.

  • ForwardTableId : ID de l'entrée DNAT.

Exemples

Scénario 1 : Créer une passerelle NAT.

Création rapide

ROSTemplateFormatVersion: '2015-09-01'
Description: Test ECS NatGateway
Parameters:
  VPC:
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
    Type: String
    Label:
      zh-cn: Existing VPC Instance ID
      en: Existing VPC Instance ID
  VSwitch:
    AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
    Type: String
    Label:
      zh-cn: VSwitch ID
      en: VSwitch ID
    AssociationPropertyMetadata:
      VpcId: VPC
Resources:
  NatGateway:
    Type: ALIYUN::VPC::NatGateway
    Properties:
      NatGatewayName: mytest
      VpcId:
        Ref: VPC
      VSwitchId:
        Ref: VSwitch
Outputs:
  NatGatewayId:
    Value:
      Fn::GetAtt:
        - NatGateway
        - NatGatewayId
  BandwidthPackageId:
    Value:
      Fn::GetAtt:
        - BandwidthPackage
        - BandwidthPackageId
  BandwidthPackageIps:
    Value:
      Fn::GetAtt:
        - CommonBandwidthPackageIp
        - IpAddresses
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": "Test ECS NatGateway",
  "Parameters": {
    "VPC": {
      "AssociationProperty": "ALIYUN::ECS::VPC::VPCId",
      "Type": "String",
      "Label": {
        "zh-cn": "Existing VPC Instance ID",
        "en": "Existing VPC Instance ID"
      }
    },
    "VSwitch": {
      "AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
      "Type": "String",
      "Label": {
        "zh-cn": "VSwitch ID",
        "en": "VSwitch ID"
      },
      "AssociationPropertyMetadata": {
        "VpcId": "VPC"
      }
    }
  },
  "Resources": {
    "NatGateway": {
      "Type": "ALIYUN::VPC::NatGateway",
      "Properties": {
        "NatGatewayName": "mytest",
        "VpcId": {
          "Ref": "VPC"
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        }
      }
    }
  },
  "Outputs": {
    "NatGatewayId": {
      "Value": {
        "Fn::GetAtt": [
          "NatGateway",
          "NatGatewayId"
        ]
      }
    },
    "BandwidthPackageId": {
      "Value": {
        "Fn::GetAtt": [
          "BandwidthPackage",
          "BandwidthPackageId"
        ]
      }
    },
    "BandwidthPackageIps": {
      "Value": {
        "Fn::GetAtt": [
          "CommonBandwidthPackageIp",
          "IpAddresses"
        ]
      }
    }
  }
}

Scénario 2 : Créer une EIP facturée à la bande passante et la lier à une passerelle NAT.

Création rapide

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  ZoneId:
    Type: String
    AssociationProperty: ZoneId
  VpcId:
    Type: String
    AssociationProperty: ALIYUN::ECS::VPC::VPCId
  VSwitchId:
    Type: String
    AssociationProperty: ALIYUN::VPC::VSwitch::VSwitchId
    AssociationPropertyMetadata:
      VpcId: ${VpcId}
      ZoneId: ${ZoneId}
Resources:
  NatGateway:
    Type: ALIYUN::VPC::NatGateway
    Properties:
      NatGatewayName: example-ngw
      VSwitchId:
        Ref: VSwitchId
      NatType: Enhanced
      VpcId:
        Ref: VpcId
      ZoneId:
        Ref: ZoneId
  Eip:
    Type: ALIYUN::VPC::EIP
    Properties:
      DeletionProtection: false
      Isp: BGP
      Bandwidth: 200
      InternetChargeType: PayByTraffic
  EipAssociation:
    Type: ALIYUN::VPC::EIPAssociation
    Properties:
      InstanceId:
        Ref: NatGateway
      AllocationId:
        Ref: Eip
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "ZoneId": {
      "Type": "String",
      "AssociationProperty": "ZoneId"
    },
    "VpcId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::VPC::VPCId"
    },
    "VSwitchId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::VPC::VSwitch::VSwitchId",
      "AssociationPropertyMetadata": {
        "VpcId": "${VpcId}",
        "ZoneId": "${ZoneId}"
      }
    }
  },
  "Resources": {
    "NatGateway": {
      "Type": "ALIYUN::VPC::NatGateway",
      "Properties": {
        "NatGatewayName": "example-ngw",
        "VSwitchId": {
          "Ref": "VSwitchId"
        },
        "NatType": "Enhanced",
        "VpcId": {
          "Ref": "VpcId"
        },
        "ZoneId": {
          "Ref": "ZoneId"
        }
      }
    },
    "Eip": {
      "Type": "ALIYUN::VPC::EIP",
      "Properties": {
        "DeletionProtection": false,
        "Isp": "BGP",
        "Bandwidth": 200,
        "InternetChargeType": "PayByTraffic"
      }
    },
    "EipAssociation": {
      "Type": "ALIYUN::VPC::EIPAssociation",
      "Properties": {
        "InstanceId": {
          "Ref": "NatGateway"
        },
        "AllocationId": {
          "Ref": "Eip"
        }
      }
    }
  }
}

Scénario 3 : Déployer une passerelle NAT Internet pour centraliser l'accès au réseau public depuis le cloud.

Création rapide

ROSTemplateFormatVersion: '2015-09-01'
Description:
  en: Create a Virtual Private Cloud (VPC) environment, configure dual-Availability Zone Elastic Compute Service (ECS) instances, and deploy a public-facing NAT Gateway to establish a unified cloud Internet access gateway.
Parameters:
  CommonName:
    Type: String
    Default: unified-egress
  ZoneId1:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
    AssociationPropertyMetadata:
      ExclusiveTo:
        - ZoneId2
    Label:
      en: Zone 1
  ZoneId2:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
    AssociationPropertyMetadata:
      ExclusiveTo:
        - ZoneId1
    Label:
      en: Zone 2
  InstanceType1:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
    AssociationPropertyMetadata:
      InstanceChargeType: PostPaid
      SystemDiskCategory: cloud_essd
      ZoneId: ${ZoneId}
    Label:
      en: ECS Instance Type 1
  InstanceType2:
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
    AssociationPropertyMetadata:
      InstanceChargeType: PostPaid
      SystemDiskCategory: cloud_essd
      ZoneId: ${ZoneId}
    Label:
      en: ECS Instance Type 2
  InstancePassword:
    NoEcho: true
    Type: String
    Description:
      en: >-
        The server login password. It must be 8 to 30 characters long and contain characters from at least three of the following categories: uppercase letters, lowercase letters, digits, and special characters: ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
    Label:
      en: Instance Password
    ConstraintDescription:
      en: >-
        The password must be 8 to 30 characters long and contain characters from at least three of the following categories: uppercase letters, lowercase letters, digits, and special characters: ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/
    AssociationProperty: 'ALIYUN::ECS::Instance::Password'
    Default: null
Resources:
  Vpc:
    Type: 'ALIYUN::ECS::VPC'
    Properties:
      CidrBlock: 192.168.0.0/16
      VpcName:
        Fn::Sub: ${CommonName}-vpc
  VSwitch1:
    Type: 'ALIYUN::ECS::VSwitch'
    Properties:
      VpcId:
        Ref: Vpc
      CidrBlock: 192.168.1.0/24
      ZoneId:
        Ref: ZoneId1
      VSwitchName:
        Fn::Sub: ${CommonName}-app1-vsw
  VSwitch2:
    Type: 'ALIYUN::ECS::VSwitch'
    Properties:
      VpcId:
        Ref: Vpc
      CidrBlock: 192.168.2.0/24
      ZoneId:
        Ref: ZoneId2
      VSwitchName:
        Fn::Sub: ${CommonName}-app2-vsw
  VSwitch3:
    Type: 'ALIYUN::ECS::VSwitch'
    Properties:
      VpcId:
        Ref: Vpc
      CidrBlock: 192.168.3.0/24
      ZoneId:
        Ref: ZoneId1
      VSwitchName:
        Fn::Sub: ${CommonName}-pub-vsw
  SecurityGroup:
    Type: 'ALIYUN::ECS::SecurityGroup'
    Properties:
      VpcId:
        Ref: Vpc
      SecurityGroupName:
        Fn::Sub: ${CommonName}-sg
      SecurityGroupIngress:
        - PortRange: 443/443
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: tcp
        - PortRange: 80/80
          SourceCidrIp: 0.0.0.0/0
          IpProtocol: tcp
  EcsInstance1:
    Type: 'ALIYUN::ECS::InstanceGroup'
    Properties:
      VpcId:
        Ref: Vpc
      ZoneId:
        Ref: ZoneId1
      VSwitchId:
        Ref: VSwitch1
      SecurityGroupId:
        Ref: SecurityGroup
      ImageId: aliyun_3_9_x64_20G_alibase_20231219.vhd
      InstanceName:
        Fn::Sub: ${CommonName}-ecs-1
      InstanceType:
        Ref: InstanceType1
      SystemDiskCategory: cloud_essd
      MaxAmount: 1
      InternetMaxBandwidthOut: 0
      Password:
        Ref: InstancePassword
  EcsInstance2:
    Type: 'ALIYUN::ECS::InstanceGroup'
    Properties:
      VpcId:
        Ref: Vpc
      ZoneId:
        Ref: ZoneId2
      VSwitchId:
        Ref: VSwitch2
      SecurityGroupId:
        Ref: SecurityGroup
      ImageId: aliyun_3_9_x64_20G_alibase_20231219.vhd
      InstanceName:
        Fn::Sub: ${CommonName}-ecs-2
      InstanceType:
        Ref: InstanceType2
      SystemDiskCategory: cloud_essd
      MaxAmount: 1
      InternetMaxBandwidthOut: 0
      Password:
        Ref: InstancePassword
  NatGateway:
    Type: 'ALIYUN::VPC::NatGateway'
    Properties:
      NatGatewayName:
        Fn::Sub: ${CommonName}-ngw
      VSwitchId:
        Ref: VSwitch3
      NatType: Enhanced
      VpcId:
        Ref: Vpc
      ZoneId:
        Ref: ZoneId1
  Eip:
    Type: 'ALIYUN::VPC::EIP'
    Properties:
      DeletionProtection: false
      Isp: BGP
      Bandwidth: 200
      InternetChargeType: PayByTraffic
  EipAssociation:
    Type: 'ALIYUN::VPC::EIPAssociation'
    Properties:
      InstanceId:
        Ref: NatGateway
      AllocationId:
        Ref: Eip
  SNat:
    Type: 'ALIYUN::VPC::SnatEntry'
    DependsOn: EipAssociation
    Properties:
      SnatTableId:
        Fn::GetAtt:
          - NatGateway
          - SNatTableId
      SnatEntryName:
        Fn::Sub: ${CommonName}-snat
      SourceVSwitchIds:
        - Ref: VSwitch1
        - Ref: VSwitch2
      SnatIp:
        Fn::GetAtt:
          - Eip
          - EipAddress
Outputs:
  EcsLoginAddress1:
    Description:
      en: ECS1 login address.
    Value:
      Fn::Sub: >-
        https://ecs-workbench.aliyun.com/?from=EcsConsole
        &instanceType=ecs&regionId=${ALIYUN::Region}&instanceId=${EcsInstance1}
  EcsLoginAddress2:
    Description:
      en: ECS2 login address.
    Value:
      Fn::Sub: >-
        https://ecs-workbench.aliyun.com/?from=EcsConsole
        &instanceType=ecs&regionId=${ALIYUN::Region}&instanceId=${EcsInstance2}
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - ZoneId1
          - ZoneId2
        Label:
          default:
            en: VSwitch Zone Configuration
      - Parameters:
          - InstanceType1
          - InstanceType2
          - InstancePassword
        Label:
          default:
            en: ECS Instance Configuration
    TemplateTags:
      - acs:technical-solution:network:implement-centralized-egress-with-internet-nat-gateway-tech_solu_134
    Hidden:
      - CommonName
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "en": "Create a Virtual Private Cloud (VPC) environment, configure dual-Availability Zone Elastic Compute Service (ECS) instances, and deploy a public-facing NAT Gateway to establish a unified cloud Internet access gateway."
  },
  "Parameters": {
    "CommonName": {
      "Type": "String",
      "Default": "unified-egress"
    },
    "ZoneId1": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
      "AssociationPropertyMetadata": {
        "ExclusiveTo": [
          "ZoneId2"
        ]
      },
      "Label": {
        "en": "Zone 1"
      }
    },
    "ZoneId2": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
      "AssociationPropertyMetadata": {
        "ExclusiveTo": [
          "ZoneId1"
        ]
      },
      "Label": {
        "en": "Zone 2"
      }
    },
    "InstanceType1": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "InstanceChargeType": "PostPaid",
        "SystemDiskCategory": "cloud_essd",
        "ZoneId": "${ZoneId}"
      },
      "Label": {
        "en": "ECS Instance Type 1"
      }
    },
    "InstanceType2": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "InstanceChargeType": "PostPaid",
        "SystemDiskCategory": "cloud_essd",
        "ZoneId": "${ZoneId}"
      },
      "Label": {
        "en": "ECS Instance Type 2"
      }
    },
    "InstancePassword": {
      "NoEcho": true,
      "Type": "String",
      "Description": {
        "en": "The server login password. It must be 8 to 30 characters long and contain characters from at least three of the following categories: uppercase letters, lowercase letters, digits, and special characters: ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
      },
      "Label": {
        "en": "Instance Password"
      },
      "ConstraintDescription": {
        "en": "The password must be 8 to 30 characters long and contain characters from at least three of the following categories: uppercase letters, lowercase letters, digits, and special characters: ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::Password",
      "Default": null
    }
  },
  "Resources": {
    "Vpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "CidrBlock": "192.168.0.0/16",
        "VpcName": {
          "Fn::Sub": "${CommonName}-vpc"
        }
      }
    },
    "VSwitch1": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "CidrBlock": "192.168.1.0/24",
        "ZoneId": {
          "Ref": "ZoneId1"
        },
        "VSwitchName": {
          "Fn::Sub": "${CommonName}-app1-vsw"
        }
      }
    },
    "VSwitch2": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "CidrBlock": "192.168.2.0/24",
        "ZoneId": {
          "Ref": "ZoneId2"
        },
        "VSwitchName": {
          "Fn::Sub": "${CommonName}-app2-vsw"
        }
      }
    },
    "VSwitch3": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "CidrBlock": "192.168.3.0/24",
        "ZoneId": {
          "Ref": "ZoneId1"
        },
        "VSwitchName": {
          "Fn::Sub": "${CommonName}-pub-vsw"
        }
      }
    },
    "SecurityGroup": {
      "Type": "ALIYUN::ECS::SecurityGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "SecurityGroupName": {
          "Fn::Sub": "${CommonName}-sg"
        },
        "SecurityGroupIngress": [
          {
            "PortRange": "443/443",
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "tcp"
          },
          {
            "PortRange": "80/80",
            "SourceCidrIp": "0.0.0.0/0",
            "IpProtocol": "tcp"
          }
        ]
      }
    },
    "EcsInstance1": {
      "Type": "ALIYUN::ECS::InstanceGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "ZoneId": {
          "Ref": "ZoneId1"
        },
        "VSwitchId": {
          "Ref": "VSwitch1"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "ImageId": "aliyun_3_9_x64_20G_alibase_20231219.vhd",
        "InstanceName": {
          "Fn::Sub": "${CommonName}-ecs-1"
        },
        "InstanceType": {
          "Ref": "InstanceType1"
        },
        "SystemDiskCategory": "cloud_essd",
        "MaxAmount": 1,
        "InternetMaxBandwidthOut": 0,
        "Password": {
          "Ref": "InstancePassword"
        }
      }
    },
    "EcsInstance2": {
      "Type": "ALIYUN::ECS::InstanceGroup",
      "Properties": {
        "VpcId": {
          "Ref": "Vpc"
        },
        "ZoneId": {
          "Ref": "ZoneId2"
        },
        "VSwitchId": {
          "Ref": "VSwitch2"
        },
        "SecurityGroupId": {
          "Ref": "SecurityGroup"
        },
        "ImageId": "aliyun_3_9_x64_20G_alibase_20231219.vhd",
        "InstanceName": {
          "Fn::Sub": "${CommonName}-ecs-2"
        },
        "InstanceType": {
          "Ref": "InstanceType2"
        },
        "SystemDiskCategory": "cloud_essd",
        "MaxAmount": 1,
        "InternetMaxBandwidthOut": 0,
        "Password": {
          "Ref": "InstancePassword"
        }
      }
    },
    "NatGateway": {
      "Type": "ALIYUN::VPC::NatGateway",
      "Properties": {
        "NatGatewayName": {
          "Fn::Sub": "${CommonName}-ngw"
        },
        "VSwitchId": {
          "Ref": "VSwitch3"
        },
        "NatType": "Enhanced",
        "VpcId": {
          "Ref": "Vpc"
        },
        "ZoneId": {
          "Ref": "ZoneId1"
        }
      }
    },
    "Eip": {
      "Type": "ALIYUN::VPC::EIP",
      "Properties": {
        "DeletionProtection": false,
        "Isp": "BGP",
        "Bandwidth": 200,
        "InternetChargeType": "PayByTraffic"
      }
    },
    "EipAssociation": {
      "Type": "ALIYUN::VPC::EIPAssociation",
      "Properties": {
        "InstanceId": {
          "Ref": "NatGateway"
        },
        "AllocationId": {
          "Ref": "Eip"
        }
      }
    },
    "SNat": {
      "Type": "ALIYUN::VPC::SnatEntry",
      "DependsOn": "EipAssociation",
      "Properties": {
        "SnatTableId": {
          "Fn::GetAtt": [
            "NatGateway",
            "SNatTableId"
          ]
        },
        "SnatEntryName": {
          "Fn::Sub": "${CommonName}-snat"
        },
        "SourceVSwitchIds": [
          {
            "Ref": "VSwitch1"
          },
          {
            "Ref": "VSwitch2"
          }
        ],
        "SnatIp": {
          "Fn::GetAtt": [
            "Eip",
            "EipAddress"
          ]
        }
      }
    }
  },
  "Outputs": {
    "EcsLoginAddress1": {
      "Description": {
        "en": "ECS1 login address."
      },
      "Value": {
        "Fn::Sub": "https://ecs-workbench.aliyun.com/?from=EcsConsole &instanceType=ecs&regionId=${ALIYUN::Region}&instanceId=${EcsInstance1}"
      }
    },
    "EcsLoginAddress2": {
      "Description": {
        "en": "ECS2 login address."
      },
      "Value": {
        "Fn::Sub": "https://ecs-workbench.aliyun.com/?from=EcsConsole &instanceType=ecs&regionId=${ALIYUN::Region}&instanceId=${EcsInstance2}"
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "ZoneId1",
            "ZoneId2"
          ],
          "Label": {
            "default": {
              "en": "VSwitch Zone Configuration"
            }
          }
        },
        {
          "Parameters": [
            "InstanceType1",
            "InstanceType2",
            "InstancePassword"
          ],
          "Label": {
            "default": {
              "en": "ECS Instance Configuration"
            }
          }
        }
      ],
      "TemplateTags": [
        "acs:technical-solution:network:implement-centralized-egress-with-internet-nat-gateway-tech_solu_134"
      ],
      "Hidden": [
        "CommonName"
      ]
    }
  }
}

Pour consulter d'autres exemples, reportez-vous aux modèles publics incluant cette ressource.