Skip to main content

nat_gateway

Gets or updates an individual nat_gateway resource, use nat_gateways to retrieve a list of resources or to create or delete a resource.

Overview

Namenat_gateway
TypeResource
DescriptionSpecifies a network address translation (NAT) gateway in the specified subnet. You can create either a public NAT gateway or a private NAT gateway. The default is a public NAT gateway. If you create a public NAT gateway, you must specify an elastic IP address.<br/> With a NAT gateway, instances in a private subnet can connect to the internet, other AWS services, or an on-premises network using the IP address of the NAT gateway. For more information, see [NAT gateways](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html) in the *Amazon VPC User Guide*.<br/> If you add a default route (AWS::EC2::Route resource) that points to a NAT gateway, specify the NAT gateway ID for the route's NatGatewayId property.<br/> When you associate an Elastic IP address or secondary Elastic IP address with a public NAT gateway, the network border group of the Elastic IP address must match the network border group of the Availability Zone (AZ) that the public NAT gateway is in. Otherwise, the NAT gateway fails to launch. You can see the network border group for the AZ by viewing the details of the subnet. Similarly, you can view the network border group for the Elastic IP address by viewing its details. For more information, see [Allocate an Elastic IP address](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-eips.html#allocate-eip) in the *Amazon VPC User Guide*.
Idaws.ec2.nat_gateway

Fields

NameDatatypeDescription
secondary_allocation_idsarraySecondary EIP allocation IDs. For more information, see [Create a NAT gateway](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html#nat-gateway-creating) in the *Amazon VPC User Guide*.
private_ip_addressstringThe private IPv4 address to assign to the NAT gateway. If you don't provide an address, a private IPv4 address will be automatically assigned.
connectivity_typestringIndicates whether the NAT gateway supports public or private connectivity. The default is public connectivity.
secondary_private_ip_addressesarraySecondary private IPv4 addresses. For more information about secondary addresses, see [Create a NAT gateway](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html#nat-gateway-creating) in the *Amazon Virtual Private Cloud User Guide*.<br/> SecondaryPrivateIpAddressCount and SecondaryPrivateIpAddresses cannot be set at the same time.
secondary_private_ip_address_countinteger[Private NAT gateway only] The number of secondary private IPv4 addresses you want to assign to the NAT gateway. For more information about secondary addresses, see [Create a NAT gateway](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html#nat-gateway-creating) in the *Amazon Virtual Private Cloud User Guide*.<br/> SecondaryPrivateIpAddressCount and SecondaryPrivateIpAddresses cannot be set at the same time.
allocation_idstring[Public NAT gateway only] The allocation ID of the Elastic IP address that's associated with the NAT gateway. This property is required for a public NAT gateway and cannot be specified with a private NAT gateway.
subnet_idstringThe ID of the subnet in which the NAT gateway is located.
nat_gateway_idstring
tagsarrayThe tags for the NAT gateway.
max_drain_duration_secondsintegerThe maximum amount of time to wait (in seconds) before forcibly releasing the IP addresses if connections are still in progress. Default value is 350 seconds.
regionstringAWS region.

Methods

NameAccessible byRequired Params
update_resourceUPDATEdata__Identifier, data__PatchDocument, region
get_resourceSELECTdata__Identifier, region

SELECT Example

SELECT
region,
secondary_allocation_ids,
private_ip_address,
connectivity_type,
secondary_private_ip_addresses,
secondary_private_ip_address_count,
allocation_id,
subnet_id,
nat_gateway_id,
tags,
max_drain_duration_seconds
FROM aws.ec2.nat_gateway
WHERE region = 'us-east-1' AND data__Identifier = '<NatGatewayId>';

Permissions

To operate on the nat_gateway resource, the following permissions are required:

Read

ec2:DescribeNatGateways

Update

ec2:DescribeNatGateways,
ec2:CreateTags,
ec2:DeleteTags,
ec2:AssociateNatGatewayAddress,
ec2:DisassociateNatGatewayAddress,
ec2:AssignPrivateNatGatewayAddress,
ec2:UnassignPrivateNatGatewayAddress