Skip to content
v2.275.0

RegionalNatGatewayProvider Class ​

Provider for Regional NAT Gateways.

Regional NAT Gateways provide automatic multi-AZ redundancy with a single gateway that scales across availability zones. Unlike zonal NAT gateways, a regional NAT gateway does not require a public subnet and is created at the VPC level.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_ec2 as interfaces_ec2 } from 'aws-cdk-lib/interfaces';

declare const eIPRef: interfaces_ec2.IEIPRef;
const regionalNatGatewayProvider = new ec2.RegionalNatGatewayProvider(/* all optional props */ {
  allocationId: 'allocationId',
  availabilityZoneAddresses: [{
    allocationIds: ['allocationIds'],

    // the properties below are optional
    availabilityZone: 'availabilityZone',
    availabilityZoneId: 'availabilityZoneId',
  }],
  eip: eIPRef,
  maxDrainDuration: cdk.Duration.minutes(30),
});
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_ec2 as ec2
from aws_cdk.interfaces import aws_ec2 as interfaces_ec2

# e_ip_ref: interfaces_ec2.IEIPRef

regional_nat_gateway_provider = ec2.RegionalNatGatewayProvider(
    allocation_id="allocationId",
    availability_zone_addresses=[ec2.AvailabilityZoneAddress(
        allocation_ids=["allocationIds"],

        # the properties below are optional
        availability_zone="availabilityZone",
        availability_zone_id="availabilityZoneId"
    )],
    eip=e_ip_ref,
    max_drain_duration=cdk.Duration.minutes(30)
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.ec2.*;
import software.amazon.awscdk.interfaces.ec2.*;

IEIPRef eIPRef;

RegionalNatGatewayProvider regionalNatGatewayProvider = RegionalNatGatewayProvider.Builder.create()
        .allocationId("allocationId")
        .availabilityZoneAddresses(List.of(AvailabilityZoneAddress.builder()
                .allocationIds(List.of("allocationIds"))

                // the properties below are optional
                .availabilityZone("availabilityZone")
                .availabilityZoneId("availabilityZoneId")
                .build()))
        .eip(eIPRef)
        .maxDrainDuration(Duration.minutes(30))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.Interfaces.EC2;

IEIPRef eIPRef;

var regionalNatGatewayProvider = new RegionalNatGatewayProvider(new RegionalNatGatewayProviderProps {
    AllocationId = "allocationId",
    AvailabilityZoneAddresses = new [] { new AvailabilityZoneAddress {
        AllocationIds = new [] { "allocationIds" },

        // the properties below are optional
        AvailabilityZone = "availabilityZone",
        AvailabilityZoneId = "availabilityZoneId"
    } },
    Eip = eIPRef,
    MaxDrainDuration = Duration.Minutes(30)
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var eIPRef IEIPRef

regionalNatGatewayProvider := awscdk.Aws_ec2.NewRegionalNatGatewayProvider(&RegionalNatGatewayProviderProps{
	AllocationId: jsii.String("allocationId"),
	AvailabilityZoneAddresses: []AvailabilityZoneAddress{
		&AvailabilityZoneAddress{
			AllocationIds: []*string{
				jsii.String("allocationIds"),
			},

			// the properties below are optional
			AvailabilityZone: jsii.String("availabilityZone"),
			AvailabilityZoneId: jsii.String("availabilityZoneId"),
		},
	},
	Eip: eIPRef,
	MaxDrainDuration: cdk.Duration_Minutes(jsii.Number(30)),
})

Initializer ​

ts
new RegionalNatGatewayProvider(props?: RegionalNatGatewayProviderProps)
python
RegionalNatGatewayProvider(props: typing.Optional[RegionalNatGatewayProviderProps] = None)
java
new RegionalNatGatewayProvider(RegionalNatGatewayProviderProps props)
csharp
new RegionalNatGatewayProvider(RegionalNatGatewayProviderProps? props = null)
go
NewRegionalNatGatewayProvider(Props RegionalNatGatewayProviderProps)

Properties ​

configuredGatewaysGatewayConfig[]configured_gatewaystyping.List[GatewayConfig]configuredGatewaysList<GatewayConfig>ConfiguredGatewaysGatewayConfig[]ConfiguredGateways*[]GatewayConfig#
Return list of gateways spawned by the provider.

A regional NAT gateway is not bound to a single Availability Zone, so az is the sentinel string 'regional' rather than a zone name.

Methods ​

configureNat(options: ConfigureNatOptions): voiddef configure_nat(self, options: ConfigureNatOptions) -> Nonepublic void configureNat(ConfigureNatOptions options)public void ConfigureNat(ConfigureNatOptions options)func ConfigureNat(Options ConfigureNatOptions)#
Called by the VPC to configure NAT.

Don't call this directly, the VPC will call it automatically.

configureSubnet(subnet: PrivateSubnet): voiddef configure_subnet(self, subnet: PrivateSubnet) -> Nonepublic void configureSubnet(PrivateSubnet subnet)public void ConfigureSubnet(PrivateSubnet subnet)func ConfigureSubnet(Subnet PrivateSubnet)#
Configures subnet with the gateway.

Don't call this directly, the VPC will call it automatically.

gateway(props?: NatGatewayProps): NatProvider@staticmethod def gateway(props: typing.Optional[NatGatewayProps] = None) -> NatProviderpublic static NatProvider gateway(NatGatewayProps props)public static NatProvider Gateway(NatGatewayProps? props = null)func Gateway(Props NatGatewayProps) NatProviderstatic#
Use NAT Gateways to provide NAT services for your VPC.

NAT gateways are managed by AWS.

instance(props: NatInstanceProps): NatInstanceProvider@staticmethod def instance(props: NatInstanceProps) -> NatInstanceProviderpublic static NatInstanceProvider instance(NatInstanceProps props)public static NatInstanceProvider Instance(NatInstanceProps props)func Instance(Props NatInstanceProps) NatInstanceProviderstaticdeprecated#
use instanceV2. 'instance' is deprecated since NatInstanceProvider uses a instance image that has reached EOL on Dec 31 2023
notes

NAT instances are managed by you, but in return allow more configuration.

Be aware that instances created using this provider will not be automatically replaced if they are stopped for any reason. You should implement your own NatProvider based on AutoScaling groups if you need that.

instanceV2(props: NatInstanceProps): NatInstanceProviderV2@staticmethod def instance_v2(props: NatInstanceProps) -> NatInstanceProviderV2public static NatInstanceProviderV2 instanceV2(NatInstanceProps props)public static NatInstanceProviderV2 InstanceV2(NatInstanceProps props)func InstanceV2(Props NatInstanceProps) NatInstanceProviderV2static#
Use NAT instances to provide NAT services for your VPC.
notes

NAT instances are managed by you, but in return allow more configuration.

Be aware that instances created using this provider will not be automatically replaced if they are stopped for any reason. You should implement your own NatProvider based on AutoScaling groups if you need that.

regionalGateway(props?: RegionalNatGatewayProviderProps): RegionalNatGatewayProvider // chainable@staticmethod def regional_gateway(props: typing.Optional[RegionalNatGatewayProviderProps] = None) -> RegionalNatGatewayProviderpublic static RegionalNatGatewayProvider regionalGateway(RegionalNatGatewayProviderProps props)public static RegionalNatGatewayProvider RegionalGateway(RegionalNatGatewayProviderProps? props = null)func RegionalGateway(Props RegionalNatGatewayProviderProps) RegionalNatGatewayProviderstatic#
Use a Regional NAT Gateway to provide NAT services for your VPC.

Regional NAT Gateways provide automatic multi-AZ redundancy with a single gateway that scales across availability zones. AWS automatically manages AZ coverage and EIP allocation.