Associates Elastic IP addresses (EIPs) and private IPv4 addresses with a public NAT gateway. For more information, see Work with NAT gateways in the Amazon VPC User Guide.
By default, you can associate up to 2 Elastic IP addresses per public NAT gateway. You can increase the limit by requesting a quota adjustment. For more information, see Elastic IP address quotas in the Amazon VPC User Guide.
When you associate an EIP or secondary EIPs with a public NAT gateway, 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 EIP will fail to associate. 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:
-
nat_gateway_id
(Optional[NatGatewayId], default:
None
)
–
The ID of the NAT gateway.
-
allocation_ids
(Optional[AllocationIdList], default:
None
)
–
The allocation IDs of EIPs that you want to associate with your NAT gateway.
-
private_ip_addresses
(Optional[IpList], default:
None
)
–
The private IPv4 addresses that you want to assign to the NAT gateway.
-
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 is UnauthorizedOperation.
-
availability_zone
(Optional[AvailabilityZoneName], default:
None
)
–
For regional NAT gateways only: The Availability Zone where you want to associate an Elastic IP address (EIP). The regional NAT gateway uses a separate EIP in each AZ to handle outbound NAT traffic from that AZ.
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.
-
availability_zone_id
(Optional[AvailabilityZoneId], default:
None
)
–
For regional NAT gateways only: The ID of the Availability Zone where you want to associate an Elastic IP address (EIP). The regional NAT gateway uses a separate EIP in each AZ to handle outbound NAT traffic from that AZ. Use this instead of AvailabilityZone for consistent identification of AZs across Amazon Web Services Regions.
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.
Raises:
Source code in docs_src/capo_ec2/_services/ec2.py
| def associate_nat_gateway_address(
self,
*,
config_overrides: Optional[EC2ClientConfig] = None,
nat_gateway_id: Optional["capo_ec2.types.nat_gateway_id.NatGatewayId"] = None,
allocation_ids: Optional[
"capo_ec2.types.allocation_id_list.AllocationIdList"
] = None,
private_ip_addresses: Optional["capo_ec2.types.ip_list.IpList"] = None,
dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
availability_zone: Optional[
"capo_ec2.types.availability_zone_name.AvailabilityZoneName"
] = None,
availability_zone_id: Optional[
"capo_ec2.types.availability_zone_id.AvailabilityZoneId"
] = None,
) -> "capo_ec2.types.associate_nat_gateway_address_result.AssociateNatGatewayAddressResult":
"""<p>Associates Elastic IP addresses (EIPs) and private IPv4 addresses with a public NAT gateway. For more information, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/nat-gateway-working-with.html">Work with NAT gateways</a> in the <i>Amazon VPC User Guide</i>.</p> <p>By default, you can associate up to 2 Elastic IP addresses per public NAT gateway. You can increase the limit by requesting a quota adjustment. For more information, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/amazon-vpc-limits.html#vpc-limits-eips">Elastic IP address quotas</a> in the <i>Amazon VPC User Guide</i>.</p> <important> <p>When you associate an EIP or secondary EIPs with a public NAT gateway, 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 EIP will fail to associate. 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 <a href="https://docs.aws.amazon.com/vpc/latest/userguide/WorkWithEIPs.html">Allocate an Elastic IP address</a> in the <i>Amazon VPC User Guide</i>. </p> </important>
Args:
nat_gateway_id: <p>The ID of the NAT gateway.</p>
allocation_ids: <p>The allocation IDs of EIPs that you want to associate with your NAT gateway.</p>
private_ip_addresses: <p>The private IPv4 addresses that you want to assign to the NAT gateway.</p>
dry_run: <p>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 <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
availability_zone: <p>For regional NAT gateways only: The Availability Zone where you want to associate an Elastic IP address (EIP). The regional NAT gateway uses a separate EIP in each AZ to handle outbound NAT traffic from that AZ.</p> <p>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.</p>
availability_zone_id: <p>For regional NAT gateways only: The ID of the Availability Zone where you want to associate an Elastic IP address (EIP). The regional NAT gateway uses a separate EIP in each AZ to handle outbound NAT traffic from that AZ. Use this instead of AvailabilityZone for consistent identification of AZs across Amazon Web Services Regions. </p> <p>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.</p>
Raises:
capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_ec2.types.associate_nat_gateway_address_request.AssociateNatGatewayAddressRequest]",
) -> OperationResponse[
"capo_ec2.types.associate_nat_gateway_address_result.AssociateNatGatewayAddressResult"
]:
import capo_ec2._operations.amazon_ec2.associate_nat_gateway_address
output, http_response = (
capo_ec2._operations.amazon_ec2.associate_nat_gateway_address.associate_nat_gateway_address(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("AssociateNatGatewayAddress")
)
input_: capo_ec2.types.associate_nat_gateway_address_request.AssociateNatGatewayAddressRequest = {}
if nat_gateway_id is not None:
input_["nat_gateway_id"] = nat_gateway_id
if allocation_ids is not None:
input_["allocation_ids"] = allocation_ids
if private_ip_addresses is not None:
input_["private_ip_addresses"] = private_ip_addresses
if dry_run is not None:
input_["dry_run"] = dry_run
if availability_zone is not None:
input_["availability_zone"] = availability_zone
if availability_zone_id is not None:
input_["availability_zone_id"] = availability_zone_id
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|