create_nat_gateway
¶
create_nat_gateway(
*,
config_overrides: Optional[EC2ClientConfig] = None,
availability_mode: Optional[AvailabilityMode] = None,
allocation_id: Optional[AllocationId] = None,
client_token: Optional[String] = None,
dry_run: Optional[Boolean] = None,
subnet_id: Optional[SubnetId] = None,
vpc_id: Optional[VpcId] = None,
availability_zone_addresses: Optional[AvailabilityZoneAddresses] = None,
tag_specifications: Optional[TagSpecificationList] = None,
connectivity_type: Optional[ConnectivityType] = None,
private_ip_address: Optional[String] = None,
secondary_allocation_ids: Optional[AllocationIdList] = None,
secondary_private_ip_addresses: Optional[IpList] = None,
secondary_private_ip_address_count: Optional[PrivateIpAddressCount] = None,
) -> CreateNatGatewayResult
Creates a NAT gateway in the specified subnet. This action creates a network interface in the specified subnet with a private IP address from the IP address range of the subnet. You can create either a public NAT gateway or a private NAT gateway.
With a public NAT gateway, internet-bound traffic from a private subnet can be routed to the NAT gateway, so that instances in a private subnet can connect to the internet.
With a private NAT gateway, private communication is routed across VPCs and on-premises networks through a transit gateway or virtual private gateway. Common use cases include running large workloads behind a small pool of allowlisted IPv4 addresses, preserving private IPv4 addresses, and communicating between overlapping networks.
For more information, see NAT gateways in the Amazon VPC User Guide.
When you create a public NAT gateway and assign it an EIP or secondary EIPs, the network border group of the EIPs must match the network border group of the Availability Zone (AZ) that the public NAT gateway is in. If it's not the same, the NAT gateway will fail to launch. You can see the network border group for the subnet's AZ by viewing the details of the subnet. Similarly, you can view the network border group of an EIP by viewing the details of the EIP address. For more information about network border groups and EIPs, see Allocate an Elastic IP address in the Amazon VPC User Guide.
Parameters:
-
availability_mode(Optional[AvailabilityMode], default:None) –Specifies whether to create a zonal (single-AZ) or regional (multi-AZ) NAT gateway. Defaults to
zonal.A zonal NAT gateway is a NAT Gateway that provides redundancy and scalability within a single availability zone. A regional NAT gateway is a single NAT Gateway that works across multiple availability zones (AZs) in your VPC, providing redundancy, scalability and availability across all the AZs in a Region.
For more information, see Regional NAT gateways for automatic multi-AZ expansion in the Amazon VPC User Guide.
-
allocation_id(Optional[AllocationId], default:None) –[Public NAT gateways only] The allocation ID of an Elastic IP address to associate with the NAT gateway. You cannot specify an Elastic IP address with a private NAT gateway. If the Elastic IP address is associated with another resource, you must first disassociate it.
-
client_token(Optional[String], default:None) –Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring idempotency.
Constraint: Maximum 64 ASCII characters.
-
dry_run(Optional[Boolean], default:None) –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. -
subnet_id(Optional[SubnetId], default:None) –The ID of the subnet in which to create the NAT gateway.
-
vpc_id(Optional[VpcId], default:None) –The ID of the VPC where you want to create a regional NAT gateway.
-
availability_zone_addresses(Optional[AvailabilityZoneAddresses], default:None) –For regional NAT gateways only: Specifies which Availability Zones you want the NAT gateway to support and the Elastic IP addresses (EIPs) to use in each AZ. The regional NAT gateway uses these EIPs to handle outbound NAT traffic from their respective AZs. If not specified, the NAT gateway will automatically expand to new AZs and associate EIPs upon detection of an elastic network interface. If you specify this parameter, auto-expansion is disabled and you must manually manage AZ coverage.
A regional NAT gateway is a single NAT Gateway that works across multiple availability zones (AZs) in your VPC, providing redundancy, scalability and availability across all the AZs in a Region.
For more information, see Regional NAT gateways for automatic multi-AZ expansion in the Amazon VPC User Guide.
-
tag_specifications(Optional[TagSpecificationList], default:None) –The tags to assign to the NAT gateway.
-
connectivity_type(Optional[ConnectivityType], default:None) –Indicates whether the NAT gateway supports public or private connectivity. The default is public connectivity.
-
private_ip_address(Optional[String], default:None) –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_allocation_ids(Optional[AllocationIdList], default:None) –Secondary EIP allocation IDs. For more information, see Create a NAT gateway in the Amazon VPC User Guide.
-
secondary_private_ip_addresses(Optional[IpList], default:None) –Secondary private IPv4 addresses. For more information about secondary addresses, see Create a NAT gateway in the Amazon VPC User Guide.
-
secondary_private_ip_address_count(Optional[PrivateIpAddressCount], default:None) –[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 VPC User Guide.
Raises:
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To create a NAT gateway This example creates a NAT gateway in subnet subnet-1a2b3c4d and associates an Elastic IP address with the allocation ID eipalloc-37fc1a52 with the NAT gateway.
Source code in docs_src/capo_ec2/_services/ec2.py
10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 10735 10736 10737 10738 10739 10740 10741 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 10774 10775 10776 10777 10778 10779 10780 10781 10782 10783 10784 10785 10786 10787 10788 10789 10790 10791 10792 10793 10794 10795 10796 10797 10798 10799 10800 10801 10802 10803 | |