HEX
Server: Apache
System: Linux vps-cdc32557.vps.ovh.ca 5.15.0-156-generic #166-Ubuntu SMP Sat Aug 9 00:02:46 UTC 2025 x86_64
User: hanode (1017)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //usr/lib/python3/dist-packages/awscli/examples/ec2/create-nat-gateway.rst
**Example 1: To create a public NAT gateway**

The following ``create-nat-gateway`` example creates a public NAT gateway in the specified subnet and associates the Elastic IP address with the specified allocation ID. When you create a public NAT gateway, you must associate an Elastic IP address. ::

    aws ec2 create-nat-gateway \ 
        --subnet-id subnet-0250c25a1fEXAMPLE \
        --allocation-id eipalloc-09ad461b0dEXAMPLE

Output::

    {
        "NatGateway": {
            "CreateTime": "2021-12-01T22:22:38.000Z",
            "NatGatewayAddresses": [
                {
                    "AllocationId": "eipalloc-09ad461b0dEXAMPLE"
                }
            ],
            "NatGatewayId": "nat-0c61bf8a12EXAMPLE",
            "State": "pending",
            "SubnetId": "subnet-0250c25a1fEXAMPLE",
            "VpcId": "vpc-0a60eb65b4EXAMPLE",
            "ConnectivityType": "public"
        }
    }

For more information, see `NAT gateways <https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html>`__ in the *Amazon VPC User Guide*.

**Example 2: To create a private NAT gateway**

The following ``create-nat-gateway`` example creates a private NAT gateway in the specified subnet. A private NAT gateway does not have an associated Elastic IP address. ::

    aws ec2 create-nat-gateway \ 
        --subnet-id subnet-0250c25a1fEXAMPLE \
        --connectivity-type private

Output::

    {
        "NatGateway": {
            "CreateTime": "2021-12-01T22:26:00.000Z",
            "NatGatewayAddresses": [
                {}
            ],
            "NatGatewayId": "nat-011b568379EXAMPLE",
            "State": "pending",
            "SubnetId": "subnet-0250c25a1fEXAMPLE",
            "VpcId": "vpc-0a60eb65b4EXAMPLE",
            "ConnectivityType": "private"
        }
    }

For more information, see `NAT gateways <https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html>`__ in the *Amazon VPC User Guide*.