class NatInstanceProviderV2
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.EC2.NatInstanceProviderV2 |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsec2#NatInstanceProviderV2 |
![]() | software.amazon.awscdk.services.ec2.NatInstanceProviderV2 |
![]() | aws_cdk.aws_ec2.NatInstanceProviderV2 |
![]() | aws-cdk-lib » aws_ec2 » NatInstanceProviderV2 |
Implements
IConnectable
Extends
Nat
Modern NAT provider which uses NAT Instances.
The instance uses Amazon Linux 2023 as the operating system.
Example
const natGatewayProvider = ec2.NatProvider.instanceV2({
instanceType: new ec2.InstanceType('t3.small'),
defaultAllowedTraffic: ec2.NatTrafficDirection.NONE,
});
const vpc = new ec2.Vpc(this, 'Vpc', { natGatewayProvider });
const securityGroup = new ec2.SecurityGroup(this, 'SecurityGroup', {
vpc,
allowAllOutbound: false,
});
securityGroup.addEgressRule(ec2.Peer.anyIpv4(), ec2.Port.tcp(443));
for (const gatewayInstance of natGatewayProvider.gatewayInstances) {
gatewayInstance.addSecurityGroup(securityGroup);
}
Initializer
new NatInstanceProviderV2(props: NatInstanceProps)
Parameters
- props
Nat
Instance Props
Properties
Name | Type | Description |
---|---|---|
configured | Gateway [] | Return list of gateways spawned by the provider. |
connections | Connections | Manage the Security Groups associated with the NAT instances. |
gateway | Instance [] | Array of gateway instances spawned by the provider after internal configuration. |
security | ISecurity | The Security Group associated with the NAT instances. |
static DEFAULT_USER_DATA_COMMANDS | string[] | Amazon Linux 2023 NAT instance user data commands Enable iptables on the instance, enable persistent IP forwarding, configure NAT on instance. |
configuredGateways
Type:
Gateway
[]
Return list of gateways spawned by the provider.
connections
Type:
Connections
Manage the Security Groups associated with the NAT instances.
gatewayInstances
Type:
Instance
[]
Array of gateway instances spawned by the provider after internal configuration.
securityGroup
Type:
ISecurity
The Security Group associated with the NAT instances.
static DEFAULT_USER_DATA_COMMANDS
Type:
string[]
Amazon Linux 2023 NAT instance user data commands Enable iptables on the instance, enable persistent IP forwarding, configure NAT on instance.
Methods
Name | Description |
---|---|
configure | Called by the VPC to configure NAT. |
configure | Configures subnet with the gateway. |
configureNat(options)
public configureNat(options: ConfigureNatOptions): void
Parameters
- options
Configure
Nat 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
Private
Subnet
Configures subnet with the gateway.
Don't call this directly, the VPC will call it automatically.