class NatProvider
| Language | Type name | 
|---|---|
|  .NET | Amazon.CDK.AWS.EC2.NatProvider | 
|  Go | github.com/aws/aws-cdk-go/awscdk/v2/awsec2#NatProvider | 
|  Java | software.amazon.awscdk.services.ec2.NatProvider | 
|  Python | aws_cdk.aws_ec2.NatProvider | 
|  TypeScript (source) | aws-cdk-lib»aws_ec2»NatProvider | 
Implemented by
Nat, Nat, Nat
NAT providers.
Determines what type of NAT provider to create, either NAT gateways or NAT instance.
Example
declare const instanceType: ec2.InstanceType;
const provider = ec2.NatProvider.instanceV2({
  instanceType,
  defaultAllowedTraffic: ec2.NatTrafficDirection.OUTBOUND_ONLY,
});
new ec2.Vpc(this, 'TheVPC', {
  natGatewayProvider: provider,
});
provider.connections.allowFrom(ec2.Peer.ipv4('1.2.3.4/8'), ec2.Port.HTTP);
Initializer
new NatProvider()
Properties
| Name | Type | Description | 
|---|---|---|
| configured | Gateway[] | Return list of gateways spawned by the provider. | 
configuredGateways
Type:
Gateway[]
Return list of gateways spawned by the provider.
Methods
| Name | Description | 
|---|---|
| configure | Called by the VPC to configure NAT. | 
| configure | 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. | 
| static instance | Use NAT instances to provide NAT services for your VPC. | 
configureNat(options) 
public configureNat(options: ConfigureNatOptions): void
Parameters
- options ConfigureNat Options 
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 NatGateway Props 
Returns
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
⚠️ Deprecated: use instanceV2. 'instance' is deprecated since NatInstanceProvider uses a instance image that has reached EOL on Dec 31 2023
Parameters
- props NatInstance Props 
Returns
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
static instanceV2(props) 
public static instanceV2(props: NatInstanceProps): NatInstanceProviderV2
Parameters
- props NatInstance Props 
Returns
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
