CreateNatGateway - Amazon Elastic Compute Cloud


Creates a NAT gateway in the specified public subnet. This action creates a network interface in the specified subnet with a private IP address from the IP address range of the subnet. Internet-bound traffic from a private subnet can be routed to the NAT gateway, therefore enabling instances in the private subnet to connect to the internet. For more information, see NAT Gateways in the Amazon Virtual Private Cloud User Guide.

Request Parameters

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.

Type: String

Required: Yes


Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see How to Ensure Idempotency.

Constraint: Maximum 64 ASCII characters.

Type: String

Required: No


Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Type: Boolean

Required: No


The subnet in which to create the NAT gateway.

Type: String

Required: Yes


The tags to assign to the NAT gateway.

Type: Array of TagSpecification objects

Required: No

Response Elements

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.

Type: String


Information about the NAT gateway.

Type: NatGateway object


The ID of the request.

Type: String


For information about the errors that are common to all actions, see Common client error codes.



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.

Sample Request &SubnetId=subnet-1a2b3c4d &AllocationId=eipalloc-37fc1a52 &AUTHPARAMS

Sample Response

<CreateNatGatewayResponse xmlns=""> <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>

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: