aws-cdk-lib.aws_ec2.NatProvider

class NatProvider

LanguageType name
.NETAmazon.CDK.AWS.EC2.NatProvider
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsec2#NatProvider
Javasoftware.amazon.awscdk.services.ec2.NatProvider
Pythonaws_cdk.aws_ec2.NatProvider
TypeScript (source)aws-cdk-lib » aws_ec2 » NatProvider

Implemented by NatInstanceProvider

NAT providers.

Determines what type of NAT provider to create, either NAT gateways or NAT instance.

Example

    // Configure the `natGatewayProvider` when defining a Vpc
    const natGatewayProvider = ec2.NatProvider.instance({
      instanceType: new ec2.InstanceType('t3.small'),
    });

    const vpc = new ec2.Vpc(this, 'MyVpc', {
      natGatewayProvider,

      // The 'natGateways' parameter now controls the number of NAT instances
      natGateways: 2,
    });

Initializer

new NatProvider()

Properties

NameTypeDescription
configuredGatewaysGatewayConfig[]Return list of gateways spawned by the provider.

configuredGateways

Type: GatewayConfig[]

Return list of gateways spawned by the provider.

Methods

NameDescription
configureNat(options)Called by the VPC to configure NAT.
configureSubnet(subnet)Configures subnet with the gateway.
static gateway(props?)Use NAT Gateways to provide NAT services for your VPC.
static instance(props)Use NAT instances to provide NAT services for your VPC.

configureNat(options)

public configureNat(options: ConfigureNatOptions): void

Parameters

  • options ConfigureNatOptions

Called by the VPC to configure NAT.

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


configureSubnet(subnet)

public configureSubnet(subnet: PrivateSubnet): void

Parameters

  • subnet PrivateSubnet

Configures subnet with the gateway.

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


static gateway(props?)

public static gateway(props?: NatGatewayProps): NatProvider

Parameters

  • props NatGatewayProps

Returns

  • NatProvider

Use NAT Gateways to provide NAT services for your VPC.

NAT gateways are managed by AWS.

See also: https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html


static instance(props)

public static instance(props: NatInstanceProps): NatInstanceProvider

Parameters

  • props NatInstanceProps

Returns

  • NatInstanceProvider

Use NAT instances to provide NAT services for your VPC.

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.

See also: https://docs.aws.amazon.com/vpc/latest/userguide/VPC_NAT_Instance.html