nat_gateways
Creates, updates, deletes or gets a nat_gateway resource or lists nat_gateways in a region
Overview
| Name | nat_gateways |
| Type | Resource |
| Description | Specifies 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.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 in the Amazon VPC User Guide.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.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 in the Amazon VPC User Guide. |
| Id | awscc.ec2.nat_gateways |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
secondary_allocation_ids | array | Secondary EIP allocation IDs. For more information, see Create a NAT gateway in the Amazon VPC User Guide. |
private_ip_address | string | The private IPv4 address to assign to the NAT gateway. If you don't provide an address, a private IPv4 address will be automatically assigned. |
secondary_private_ip_address_count | integer | [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 in the Amazon Virtual Private Cloud User Guide.SecondaryPrivateIpAddressCount and SecondaryPrivateIpAddresses cannot be set at the same time. |
allocation_id | string | [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_id | string | The ID of the subnet in which the NAT gateway is located. |
connectivity_type | string | Indicates whether the NAT gateway supports public or private connectivity. The default is public connectivity. |
secondary_private_ip_addresses | array | Secondary private IPv4 addresses. For more information about secondary addresses, see Create a NAT gateway in the Amazon Virtual Private Cloud User Guide.SecondaryPrivateIpAddressCount and SecondaryPrivateIpAddresses cannot be set at the same time. |
nat_gateway_id | string | |
tags | array | The tags for the NAT gateway. |
max_drain_duration_seconds | integer | The 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. |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
nat_gateway_id | string | |
region | string | AWS region. |
For more information, see AWS::EC2::NatGateway.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | nat_gateways | INSERT | region |
delete_resource | nat_gateways | DELETE | Identifier, region |
update_resource | nat_gateways | UPDATE | Identifier, PatchDocument, region |
list_resources | nat_gateways_list_only | SELECT | region |
get_resource | nat_gateways | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
Gets all properties from an individual nat_gateway.
SELECT
region,
secondary_allocation_ids,
private_ip_address,
secondary_private_ip_address_count,
allocation_id,
subnet_id,
connectivity_type,
secondary_private_ip_addresses,
nat_gateway_id,
tags,
max_drain_duration_seconds
FROM awscc.ec2.nat_gateways
WHERE
region = '{{ region }}' AND
Identifier = '{{ nat_gateway_id }}';
Lists all nat_gateways in a region.
SELECT
region,
nat_gateway_id
FROM awscc.ec2.nat_gateways_list_only
WHERE
region = '{{ region }}';
INSERT example
Use the following StackQL query and manifest file to create a new nat_gateway resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO awscc.ec2.nat_gateways (
SecondaryAllocationIds,
PrivateIpAddress,
SecondaryPrivateIpAddressCount,
AllocationId,
SubnetId,
ConnectivityType,
SecondaryPrivateIpAddresses,
Tags,
MaxDrainDurationSeconds,
region
)
SELECT
'{{ secondary_allocation_ids }}',
'{{ private_ip_address }}',
'{{ secondary_private_ip_address_count }}',
'{{ allocation_id }}',
'{{ subnet_id }}',
'{{ connectivity_type }}',
'{{ secondary_private_ip_addresses }}',
'{{ tags }}',
'{{ max_drain_duration_seconds }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
/*+ create */
INSERT INTO awscc.ec2.nat_gateways (
SecondaryAllocationIds,
PrivateIpAddress,
SecondaryPrivateIpAddressCount,
AllocationId,
SubnetId,
ConnectivityType,
SecondaryPrivateIpAddresses,
Tags,
MaxDrainDurationSeconds,
region
)
SELECT
'{{ secondary_allocation_ids }}',
'{{ private_ip_address }}',
'{{ secondary_private_ip_address_count }}',
'{{ allocation_id }}',
'{{ subnet_id }}',
'{{ connectivity_type }}',
'{{ secondary_private_ip_addresses }}',
'{{ tags }}',
'{{ max_drain_duration_seconds }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: nat_gateway
props:
- name: secondary_allocation_ids
value:
- '{{ secondary_allocation_ids[0] }}'
- name: private_ip_address
value: '{{ private_ip_address }}'
- name: secondary_private_ip_address_count
value: '{{ secondary_private_ip_address_count }}'
- name: allocation_id
value: '{{ allocation_id }}'
- name: subnet_id
value: '{{ subnet_id }}'
- name: connectivity_type
value: '{{ connectivity_type }}'
- name: secondary_private_ip_addresses
value:
- '{{ secondary_private_ip_addresses[0] }}'
- name: tags
value:
- key: '{{ key }}'
value: '{{ value }}'
- name: max_drain_duration_seconds
value: '{{ max_drain_duration_seconds }}'
UPDATE example
Use the following StackQL query and manifest file to update a nat_gateway resource, using stack-deploy.
/*+ update */
UPDATE awscc.ec2.nat_gateways
SET PatchDocument = string('{{ {
"SecondaryAllocationIds": secondary_allocation_ids,
"SecondaryPrivateIpAddressCount": secondary_private_ip_address_count,
"SecondaryPrivateIpAddresses": secondary_private_ip_addresses,
"Tags": tags,
"MaxDrainDurationSeconds": max_drain_duration_seconds
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ nat_gateway_id }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
DELETE example
/*+ delete */
DELETE FROM awscc.ec2.nat_gateways
WHERE
Identifier = '{{ nat_gateway_id }}' AND
region = '{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
Additional Parameters
Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with INSERT, UPDATE, or DELETE operations. These include:
| Parameter | Description |
|---|---|
ClientToken | A unique identifier to ensure the idempotency of the resource request.This allows the provider to accurately distinguish between retries and new requests.A client token is valid for 36 hours once used. After that, a resource request with the same client token is treated as a new request. If you do not specify a client token, one is generated for inclusion in the request. |
RoleArn | The ARN of the IAM role used to perform this resource operation.The role specified must have the permissions required for this operation.If you do not specify a role, a temporary session is created using your AWS user credentials. |
TypeVersionId | For private resource types, the type version to use in this resource operation.If you do not specify a resource version, the default version is used. |
Permissions
To operate on the nat_gateways resource, the following permissions are required:
- Read
- Create
- Update
- List
- Delete
ec2:DescribeNatGateways
ec2:CreateNatGateway,
ec2:DescribeNatGateways,
ec2:CreateTags
ec2:DescribeNatGateways,
ec2:CreateTags,
ec2:DeleteTags,
ec2:AssociateNatGatewayAddress,
ec2:DisassociateNatGatewayAddress,
ec2:AssignPrivateNatGatewayAddress,
ec2:UnassignPrivateNatGatewayAddress
ec2:DescribeNatGateways
ec2:DeleteNatGateway,
ec2:DescribeNatGateways