ALIYUN::VPC::NatGateway is used to create a NAT gateway.

Syntax

{
  "Type": "ALIYUN::VPC::NatGateway",
  "Properties": {
    "Description": String,
    "NatGatewayName": String,
    "InstanceChargeType": String,
    "PricingCycle": String,
    "VSwitchId": String,
    "Duration": Number,
    "DeletionProtection": Boolean,
    "InternetChargeType": String,
    "AutoPay": Boolean,
    "NatType": String,
    "DeletionForce": Boolean,
    "VpcId": String,
    "Tags": List,
    "NetworkType": String
  }
}

Properties

Property Type Required Editable Description Constraint
Description String No No The description of the NAT gateway. The description must be 2 to 256 characters in length, and cannot start with http:// or https://.
NatGatewayName String No No The name of the NAT gateway.

The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter but cannot start with http:// or https://.

If you do not specify this property, the gateway ID is used as the gateway name.

InstanceChargeType String No No The billing method of the NAT gateway. Default value: PostPaid. Valid values:
  • PostPaid: the pay-as-you-go billing method
  • PrePaid: the subscription billing method
PricingCycle String No No The billing cycle of the subscription NAT gateway. Default value: Month. Valid values:
  • Month
  • Year
This property is required when you set the InstanceChargeType property to PrePaid.
VSwitchId String Yes No The ID of the vSwitch to which the NAT gateway is attached. When you create an enhanced NAT gateway, you must specify a vSwitch for the NAT gateway. Then, the system assigns an idle private IP address from the vSwitch to the NAT gateway.
  • If you want to create an enhanced NAT gateway that is attached to an existing vSwitch, you must make sure that the zone to which the vSwitch belongs supports enhanced NAT gateways. In addition, the vSwitch must have idle IP addresses.
  • If you want to create an enhanced NAT gateway when you do not have a vSwitch, you must create a vSwitch in a zone that supports enhanced NAT gateways. Then, you can specify the vSwitch for the enhanced NAT gateway.
You can call the ListEnhanhcedNatGatewayAvailableZones operation to query the zones that support enhanced NAT gateways and call the DescribeVSwitches operation to query idle IP addresses in a vSwitch.
Duration Number No No The subscription duration.
  • Valid values if you set the PricingCycle property to Month: 1 to 9.
  • Valid values if you set the PricingCycle property to Year: 1 to 3.

This property is required when you set the InstanceChargeType property to PrePaid.

DeletionProtection Boolean No No Specifies whether to enable deletion protection. Valid values:
  • true: enables deletion protection.
  • false: disables deletion protection.
InternetChargeType String No No The metering method of the NAT gateway. Set the value to PayByLcu, which specifies the pay-by-CU metering method.
AutoPay Boolean No No Specifies whether to enable automatic payment. Valid values:
  • false: disables automatic payment. After an order is generated, you must go to the order center to complete the payment.
  • true: enables automatic payment. This is the default value. After an order is generated, the system automatically deducts the payment from your account balance to pay for the order.
This property is required when you set the InstanceChargeType property to PrePaid.
NatType String No No The type of the NAT gateway. Set the value to Enhanced, which specifies an enhanced NAT gateway.
DeletionForce Boolean No No Specifies whether to force delete the NAT gateway. Valid values:
  • true: force deletes the NAT gateway.
  • false: does not force delete the NAT gateway.
VpcId String Yes No The ID of the virtual private cloud (VPC) in which you create the NAT gateway. If you want to create a standard NAT gateway in a VPC, you must make sure that the route table of the VPC does not contain a route entry whose destination CIDR block is set to 0.0.0.0/0. If a route entry whose destination CIDR block is set to 0.0.0.0/0 exists, you must delete the route entry before you create the standard NAT gateway.
Note The preceding limit does not apply when you create an enhanced NAT gateway in a VPC.
NetworkType String No No The network type of the NAT gateway. Default value: Internet. Valid values:
  • Internet: an Internet NAT gateway
  • Intranet: a VPC NAT gateway
Tags List No Yes The tags. You can bind up to 20 tags to the NAT gateway.

For more information, see Tags syntax and Tags properties.

Tags syntax

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

Tags properties

Property Type Required Editable Description Constraint
Key String Yes No The key of the tag. The tag key must be 1 to 64 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The key cannot contain http:// or https://. The key cannot start with acs: or aliyun.
Value String No No The value of the tag. The tag value must be 0 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The value cannot contain http:// or https://. The value cannot start with acs: or aliyun.

Return values

Fn::GetAtt

  • NatGatewayId: the ID of the NAT gateway.
  • SNatTableId: the ID of the SNAT entry.
  • ForwardTableId: the ID of the DNAT entry.

Examples

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "Description": {
      "Type": "String",
      "Description": "Description of the NAT gateway, [2, 256] characters. Do not fill or empty, the default is empty."
    },
    "NatGatewayName": {
      "Type": "String",
      "Description": "Display name of the NAT gateway, [2, 128] English or Chinese characters, must start with a letter or Chinese in size, can contain numbers, '_' or '.', '-'"
    },
    "InstanceChargeType": {
      "Type": "String",
      "Description": "The billing method. The default value is PostPaid (which means pay-as-you-go).",
      "AllowedValues": [
        "PrePaid",
        "PostPaid"
      ],
      "Default": "PostPaid"
    },
    "PricingCycle": {
      "Type": "String",
      "Description": "Price cycle of the resource. This property has no default value.",
      "AllowedValues": [
        "Month",
        "Year"
      ]
    },
    "VSwitchId": {
      "Type": "String",
      "Description": "The VSwitch id to create NAT gateway."
    },
    "Duration": {
      "Type": "Number",
      "Description": "The subscription duration. While choose by pay by month, it could be from 1 to 9. While choose pay by year, it could be from 1 to 3.",
      "MinValue": 1,
      "MaxValue": 9,
      "Default": 1
    },
    "InternetChargeType": {
      "Type": "String",
      "Description": "The billing method for the NAT gateway. Valid values:\nPayByLcu: billed on a pay-by-LCU basis.",
      "AllowedValues": [
        "PayByLcu"
      ]
    },
    "DeletionProtection": {
      "Type": "Boolean",
      "Description": "Whether to enable deletion protection.\nDefault to False.",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ],
      "Default": false
    },
    "AutoPay": {
      "Type": "Boolean",
      "Description": "Specifies whether to enable automatic payment. Default is false.",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ],
      "Default": true
    },
    "NatType": {
      "Type": "String",
      "Description": "The type of the NAT gateway. Valid values:\n- Enhanced: enhanced NAT gateway.",
      "AllowedValues": [
        "Enhanced"
      ],
      "Default": "Enhanced"
    },
    "DeletionForce": {
      "Type": "Boolean",
      "Description": "Whether force delete the relative snat and dnat entries in the net gateway and unbind eips. Default value is false.",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ],
      "Default": false
    },
    "VpcId": {
      "Type": "String",
      "Description": "The VPC id to create NAT gateway."
    },
    "Tags": {
      "Type": "Json",
      "Description": "Tags to attach to natgateway. Max support 20 tags to add during create natgateway. Each tag with two properties Key and Value, and Key is required.",
      "MaxLength": 20
    },
    "NetworkType": {
      "Type": "String",
      "Description": "The type of NAT gateway created."
    }
  },
  "Resources": {
    "VpcNatGateway": {
      "Type": "ALIYUN::VPC::NatGateway",
      "Properties": {
        "Description": {
          "Ref": "Description"
        },
        "NatGatewayName": {
          "Ref": "NatGatewayName"
        },
        "InstanceChargeType": {
          "Ref": "InstanceChargeType"
        },
        "PricingCycle": {
          "Ref": "PricingCycle"
        },
        "VSwitchId": {
          "Ref": "VSwitchId"
        },
        "InternetChargeType": {
          "Ref": "InternetChargeType"
        },
        "Duration": {
          "Ref": "Duration"
        },
        "DeletionProtection": {
          "Ref": "DeletionProtection"
        },
        "AutoPay": {
          "Ref": "AutoPay"
        },
        "NatType": {
          "Ref": "NatType"
        },
        "DeletionForce": {
          "Ref": "DeletionForce"
        },
        "VpcId": {
          "Ref": "VpcId"
        },
        "Tags": {
          "Ref": "Tags"
        },
        "NetworkType": {
          "Ref": "NetworkType"
        }
      }
    }
  },
  "Outputs": {
    "NatGatewayId": {
      "Description": "The Id of created NAT gateway.",
      "Value": {
        "Fn::GetAtt": [
          "VpcNatGateway",
          "NatGatewayId"
        ]
      }
    },
    "SNatTableId": {
      "Description": "The SNAT table id.",
      "Value": {
        "Fn::GetAtt": [
          "VpcNatGateway",
          "SNatTableId"
        ]
      }
    },
    "ForwardTableId": {
      "Description": "The forward table id.",
      "Value": {
        "Fn::GetAtt": [
          "VpcNatGateway",
          "ForwardTableId"
        ]
      }
    }
  }
}

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  Description:
    Type: String
    Description: Description of the NAT gateway, [2, 256] characters. Do not fill
      or empty, the default is empty.
  NatGatewayName:
    Type: String
    Description: Display name of the NAT gateway, [2, 128] English or Chinese characters,
      must start with a letter or Chinese in size, can contain numbers, '_' or '.',
      '-'
  InstanceChargeType:
    Type: String
    Description: The billing method. The default value is PostPaid (which means pay-as-you-go).
    AllowedValues:
    - PrePaid
    - PostPaid
    Default: PostPaid
  PricingCycle:
    Type: String
    Description: Price cycle of the resource. This property has no default value.
    AllowedValues:
    - Month
    - Year
  VSwitchId:
    Type: String
    Description: The VSwitch id to create NAT gateway.
  Duration:
    Type: Number
    Description: The subscription duration. While choose by pay by month, it could
      be from 1 to 9. While choose pay by year, it could be from 1 to 3.
    MinValue: 1
    MaxValue: 9
    Default: 1
  InternetChargeType:
    Type: String
    Description: |-
      The billing method for the NAT gateway. Valid values:
      PayByLcu: billed on a pay-by-LCU basis.
    AllowedValues:
    - PayByLcu
  DeletionProtection:
    Type: Boolean
    Description: |-
      Whether to enable deletion protection.
      Default to False.
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Default: false
  AutoPay:
    Type: Boolean
    Description: Specifies whether to enable automatic payment. Default is true.
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Default: true
  NatType:
    Type: String
    Description: |-
      The type of the NAT gateway. Valid values:
      - Enhanced: enhanced NAT gateway.
    AllowedValues:
    - Enhanced
    Default: Enhanced
  DeletionForce:
    Type: Boolean
    Description: Whether force delete the relative snat and dnat entries in the net
      gateway and unbind eips. Default value is false.
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Default: false
  VpcId:
    Type: String
    Description: The VPC id to create NAT gateway.
  Tags:
    Type: Json
    Description: Tags to attach to natgateway. Max support 20 tags to add during create
      natgateway. Each tag with two properties Key and Value, and Key is required.
    MaxLength: 20
  NetworkType:
    Type: String
    Description: The type of NAT gateway created.
Resources:
  VpcNatGateway:
    Type: ALIYUN::VPC::NatGateway
    Properties:
      Description:
        Ref: Description
      NatGatewayName:
        Ref: NatGatewayName
      InstanceChargeType:
        Ref: InstanceChargeType
      PricingCycle:
        Ref: PricingCycle
      VSwitchId:
        Ref: VSwitchId
      InternetChargeType:
        Ref: InternetChargeType
      Duration:
        Ref: Duration
      DeletionProtection:
        Ref: DeletionProtection
      AutoPay:
        Ref: AutoPay
      NatType:
        Ref: NatType
      DeletionForce:
        Ref: DeletionForce
      VpcId:
        Ref: VpcId
      Tags:
        Ref: Tags
      NetworkType:
        Ref: NetworkType
Outputs:
  NatGatewayId:
    Description: The Id of created NAT gateway.
    Value:
      Fn::GetAtt:
      - VpcNatGateway
      - NatGatewayId
  SNatTableId:
    Description: The SNAT table id.
    Value:
      Fn::GetAtt:
      - VpcNatGateway
      - SNatTableId
  ForwardTableId:
    Description: The forward table id.
    Value:
      Fn::GetAtt:
      - VpcNatGateway
      - ForwardTableId

To view more examples, visit NatGateway.json and NatGateway.yml.