Creates a NAT gateway in the specified subnet. A NAT gateway can be used to enable instances in a private subnet to connect to the Internet. This action creates a network interface in the specified subnet with a private IP address from the IP address range of the subnet. For more information, see NAT Gateways in the Amazon Virtual Private Cloud User Guide.
The following parameters are for this specific action. For more information about required and optional parameters that are common to all actions, see Common Query Parameters.
The allocation ID of an Elastic IP address to associate with the NAT gateway. If the Elastic IP address is associated with another resource, you must first disassociate it.
Unique, case-sensitive identifier you provide to ensure the idempotency of the request. For more information, see How to Ensure Idempotency.
Constraint: Maximum 64 ASCII characters.
The subnet in which to create the NAT gateway.
The following elements are returned by the service.
Unique, case-sensitive identifier to ensure the idempotency of the request. Only returned if a client token was provided in the request.
Information about the NAT gateway.
Type: NatGateway object
The ID of the request.
For information about the errors that are common to all actions, see Common Errors.
This example creates a NAT gateway in subnet subnet-1a2b3c4d and associates the Elastic IP address (with the allocation ID eipalloc-37fc1a52) to the NAT gateway.
https://ec2.amazonaws.com/?Action=CreateNatGateway &SubnetId=subnet-1a2b3c4d &AllocationId=eipalloc-37fc1a52 &AUTHPARAMS
<CreateNatGatewayResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>1b74dc5c-bcda-403f-867d-example</requestId> <natGateway> <subnetId>subnet-1a2b3c4d</subnetId> <natGatewayAddressSet> <item> <allocationId>eipalloc-37fc1a52</allocationId> </item> </natGatewayAddressSet> <createTime>2015-11-25T14:00:55.416Z</createTime> <vpcId>vpc-4e20d42b</vpcId> <natGatewayId>nat-04e77a5e9c34432f9</natGatewayId> <state>pending</state> </natGateway> </CreateNatGatewayResponse>
For more information about using this API in one of the language-specific AWS SDKs, see the following: