EC2 / Client / describe_nat_gateways
describe_nat_gateways#
- EC2.Client.describe_nat_gateways(**kwargs)#
Describes your NAT gateways. The default is to describe all your NAT gateways. Alternatively, you can specify specific NAT gateway IDs or filter the results to include only the NAT gateways that match specific criteria.
See also: AWS API Documentation
Request Syntax
response = client.describe_nat_gateways( DryRun=True|False, Filters=[ { 'Name': 'string', 'Values': [ 'string', ] }, ], MaxResults=123, NatGatewayIds=[ 'string', ], NextToken='string' )
- Parameters:
DryRun (boolean) – 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 isUnauthorizedOperation
.Filters (list) –
The filters.
nat-gateway-id
- The ID of the NAT gateway.state
- The state of the NAT gateway (pending
|failed
|available
|deleting
|deleted
).subnet-id
- The ID of the subnet in which the NAT gateway resides.tag
- The key/value combination of a tag assigned to the resource. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the keyOwner
and the valueTeamA
, specifytag:Owner
for the filter name andTeamA
for the filter value.tag-key
- The key of a tag assigned to the resource. Use this filter to find all resources assigned a tag with a specific key, regardless of the tag value.vpc-id
- The ID of the VPC in which the NAT gateway resides.
(dict) –
A filter name and value pair that is used to return a more specific list of results from a describe operation. Filters can be used to match a set of resources by specific criteria, such as tags, attributes, or IDs.
If you specify multiple filters, the filters are joined with an
AND
, and the request returns only results that match all of the specified filters.Name (string) –
The name of the filter. Filter names are case-sensitive.
Values (list) –
The filter values. Filter values are case-sensitive. If you specify multiple values for a filter, the values are joined with an
OR
, and the request returns all results that match any of the specified values.(string) –
MaxResults (integer) – The maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see Pagination.
NatGatewayIds (list) –
The IDs of the NAT gateways.
(string) –
NextToken (string) – The token returned from a previous paginated request. Pagination continues from the end of the items returned by the previous request.
- Return type:
dict
- Returns:
Response Syntax
{ 'NatGateways': [ { 'CreateTime': datetime(2015, 1, 1), 'DeleteTime': datetime(2015, 1, 1), 'FailureCode': 'string', 'FailureMessage': 'string', 'NatGatewayAddresses': [ { 'AllocationId': 'string', 'NetworkInterfaceId': 'string', 'PrivateIp': 'string', 'PublicIp': 'string', 'AssociationId': 'string', 'IsPrimary': True|False, 'FailureMessage': 'string', 'Status': 'assigning'|'unassigning'|'associating'|'disassociating'|'succeeded'|'failed' }, ], 'NatGatewayId': 'string', 'ProvisionedBandwidth': { 'ProvisionTime': datetime(2015, 1, 1), 'Provisioned': 'string', 'RequestTime': datetime(2015, 1, 1), 'Requested': 'string', 'Status': 'string' }, 'State': 'pending'|'failed'|'available'|'deleting'|'deleted', 'SubnetId': 'string', 'VpcId': 'string', 'Tags': [ { 'Key': 'string', 'Value': 'string' }, ], 'ConnectivityType': 'private'|'public' }, ], 'NextToken': 'string' }
Response Structure
(dict) –
NatGateways (list) –
Information about the NAT gateways.
(dict) –
Describes a NAT gateway.
CreateTime (datetime) –
The date and time the NAT gateway was created.
DeleteTime (datetime) –
The date and time the NAT gateway was deleted, if applicable.
FailureCode (string) –
If the NAT gateway could not be created, specifies the error code for the failure. (
InsufficientFreeAddressesInSubnet
|Gateway.NotAttached
|InvalidAllocationID.NotFound
|Resource.AlreadyAssociated
|InternalError
|InvalidSubnetID.NotFound
)FailureMessage (string) –
If the NAT gateway could not be created, specifies the error message for the failure, that corresponds to the error code.
For InsufficientFreeAddressesInSubnet: “Subnet has insufficient free addresses to create this NAT gateway”
For Gateway.NotAttached: “Network vpc-xxxxxxxx has no Internet gateway attached”
For InvalidAllocationID.NotFound: “Elastic IP address eipalloc-xxxxxxxx could not be associated with this NAT gateway”
For Resource.AlreadyAssociated: “Elastic IP address eipalloc-xxxxxxxx is already associated”
For InternalError: “Network interface eni-xxxxxxxx, created and used internally by this NAT gateway is in an invalid state. Please try again.”
For InvalidSubnetID.NotFound: “The specified subnet subnet-xxxxxxxx does not exist or could not be found.”
NatGatewayAddresses (list) –
Information about the IP addresses and network interface associated with the NAT gateway.
(dict) –
Describes the IP addresses and network interface associated with a NAT gateway.
AllocationId (string) –
[Public NAT gateway only] The allocation ID of the Elastic IP address that’s associated with the NAT gateway.
NetworkInterfaceId (string) –
The ID of the network interface associated with the NAT gateway.
PrivateIp (string) –
The private IP address associated with the NAT gateway.
PublicIp (string) –
[Public NAT gateway only] The Elastic IP address associated with the NAT gateway.
AssociationId (string) –
[Public NAT gateway only] The association ID of the Elastic IP address that’s associated with the NAT gateway.
IsPrimary (boolean) –
Defines if the IP address is the primary address.
FailureMessage (string) –
The address failure message.
Status (string) –
The address status.
NatGatewayId (string) –
The ID of the NAT gateway.
ProvisionedBandwidth (dict) –
Reserved. If you need to sustain traffic greater than the documented limits, contact Amazon Web Services Support.
ProvisionTime (datetime) –
Reserved.
Provisioned (string) –
Reserved.
RequestTime (datetime) –
Reserved.
Requested (string) –
Reserved.
Status (string) –
Reserved.
State (string) –
The state of the NAT gateway.
pending
: The NAT gateway is being created and is not ready to process traffic.failed
: The NAT gateway could not be created. Check thefailureCode
andfailureMessage
fields for the reason.available
: The NAT gateway is able to process traffic. This status remains until you delete the NAT gateway, and does not indicate the health of the NAT gateway.deleting
: The NAT gateway is in the process of being terminated and may still be processing traffic.deleted
: The NAT gateway has been terminated and is no longer processing traffic.
SubnetId (string) –
The ID of the subnet in which the NAT gateway is located.
VpcId (string) –
The ID of the VPC in which the NAT gateway is located.
Tags (list) –
The tags for the NAT gateway.
(dict) –
Describes a tag.
Key (string) –
The key of the tag.
Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters. May not begin with
aws:
.Value (string) –
The value of the tag.
Constraints: Tag values are case-sensitive and accept a maximum of 256 Unicode characters.
ConnectivityType (string) –
Indicates whether the NAT gateway supports public or private connectivity.
NextToken (string) –
The token to include in another request to get the next page of items. This value is
null
when there are no more items to return.
Examples
This example describes the NAT gateway for the specified VPC.
response = client.describe_nat_gateways( Filter=[ { 'Name': 'vpc-id', 'Values': [ 'vpc-1a2b3c4d', ], }, ], ) print(response)
Expected Output:
{ 'NatGateways': [ { 'CreateTime': datetime(2015, 12, 1, 12, 26, 55, 1, 335, 0), 'NatGatewayAddresses': [ { 'AllocationId': 'eipalloc-89c620ec', 'NetworkInterfaceId': 'eni-9dec76cd', 'PrivateIp': '10.0.0.149', 'PublicIp': '198.11.222.333', }, ], 'NatGatewayId': 'nat-05dba92075d71c408', 'State': 'available', 'SubnetId': 'subnet-847e4dc2', 'VpcId': 'vpc-1a2b3c4d', }, ], 'ResponseMetadata': { '...': '...', }, }