> **Experimental**
>
> `@aws-cdk/aws-ec2-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# NatGatewayOptions

Options to define a NAT gateway.

Used as argument in: [IVpcV2.addNatGateway](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-ec2-alpha.IVpcV2.html#addnatgateway)

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- Source: [`lib/route.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-ec2-alpha/lib/route.ts#L95)

## Example

TypeScript:

```ts
const stack = new Stack();
const myVpc = new VpcV2(this, 'Vpc');
const routeTable = new RouteTable(this, 'RouteTable', {
  vpc: myVpc,
});
const subnet = new SubnetV2(this, 'Subnet', {
  vpc: myVpc,
  availabilityZone: 'eu-west-2a',
  ipv4CidrBlock: new IpCidr('10.0.0.0/24'),
  subnetType: SubnetType.PUBLIC });

myVpc.addInternetGateway();
myVpc.addNatGateway({
  subnet: subnet,
  connectivityType: NatConnectivityType.PUBLIC,
});
```

Python:

```python
stack = Stack()
my_vpc = VpcV2(self, "Vpc")
route_table = RouteTable(self, "RouteTable",
    vpc=my_vpc
)
subnet = SubnetV2(self, "Subnet",
    vpc=my_vpc,
    availability_zone="eu-west-2a",
    ipv4_cidr_block=IpCidr("10.0.0.0/24"),
    subnet_type=SubnetType.PUBLIC
)

my_vpc.add_internet_gateway()
my_vpc.add_nat_gateway(
    subnet=subnet,
    connectivity_type=NatConnectivityType.PUBLIC
)
```

Java:

```java
Stack stack = new Stack();
VpcV2 myVpc = new VpcV2(this, "Vpc");
RouteTable routeTable = RouteTable.Builder.create(this, "RouteTable")
        .vpc(myVpc)
        .build();
SubnetV2 subnet = SubnetV2.Builder.create(this, "Subnet")
        .vpc(myVpc)
        .availabilityZone("eu-west-2a")
        .ipv4CidrBlock(new IpCidr("10.0.0.0/24"))
        .subnetType(SubnetType.PUBLIC)
        .build();

myVpc.addInternetGateway();
myVpc.addNatGateway(NatGatewayOptions.builder()
        .subnet(subnet)
        .connectivityType(NatConnectivityType.PUBLIC)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.ec2.Alpha
var stack = new Stack();
var myVpc = new VpcV2(this, "Vpc");
var routeTable = new RouteTable(this, "RouteTable", new RouteTableProps {
    Vpc = myVpc
});
var subnet = new SubnetV2(this, "Subnet", new SubnetV2Props {
    Vpc = myVpc,
    AvailabilityZone = "eu-west-2a",
    Ipv4CidrBlock = new IpCidr("10.0.0.0/24"),
    SubnetType = SubnetType.PUBLIC
});

myVpc.AddInternetGateway();
myVpc.AddNatGateway(new NatGatewayOptions {
    Subnet = subnet,
    ConnectivityType = NatConnectivityType.PUBLIC
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsec2alpha/v2
stack := awscdk.Newstack()
myVpc := awsec2alpha.NewVpcV2(this, jsii.String("Vpc"))
routeTable := awsec2alpha.NewRouteTable(this, jsii.String("RouteTable"), &RouteTableProps{
	Vpc: myVpc,
})
subnet := awsec2alpha.NewSubnetV2(this, jsii.String("Subnet"), &SubnetV2Props{
	Vpc: myVpc,
	AvailabilityZone: jsii.String("eu-west-2a"),
	Ipv4CidrBlock: awsec2alpha.NewIpCidr(jsii.String("10.0.0.0/24")),
	SubnetType: awscdk.SubnetType_PUBLIC,
})

myVpc.AddInternetGateway()
myVpc.AddNatGateway(&NatGatewayOptions{
	Subnet: subnet,
	ConnectivityType: awsec2alpha.NatConnectivityType_PUBLIC,
})
```

## Properties

- `allocationId`: string — AllocationID of Elastic IP address that's associated with the NAT gateway.

  **Default:** attr.allocationID of a new Elastic IP created by default //TODO: ADD L2 for elastic ip

  This property is required for a public NAT
  gateway and cannot be specified with a private NAT gateway.

- `connectivityType`: [NatConnectivityType](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-ec2-alpha.NatConnectivityType.html) = NatConnectivityType.Public — Indicates whether the NAT gateway supports public or private connectivity.

- `maxDrainDuration`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.seconds(350) — The maximum amount of time to wait before forcibly releasing the IP addresses if connections are still in progress.

- `natGatewayName`: string — The resource name of the NAT gateway.

  **Default:** NATGW provisioned without any name

- `privateIpAddress`: string — The private IPv4 address to assign to the NAT gateway.

  **Default:** If you don't provide an address, a private IPv4 address will be automatically assigned.

- `secondaryAllocationIds`: string[] — Secondary EIP allocation IDs.

  **Default:** no secondary allocation IDs attached to NATGW

- `secondaryPrivateIpAddressCount`: number — The number of secondary private IPv4 addresses you want to assign to the NAT gateway.

  **Default:** no secondary allocation IDs associated with NATGW

  `SecondaryPrivateIpAddressCount` and `SecondaryPrivateIpAddresses` cannot be
  set at the same time.

- `secondaryPrivateIpAddresses`: string[] — Secondary private IPv4 addresses.

  **Default:** no secondary private IpAddresses associated with NATGW

  `SecondaryPrivateIpAddressCount` and `SecondaryPrivateIpAddresses` cannot be
  set at the same time.

- `subnet`: [ISubnetV2](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-ec2-alpha.ISubnetV2.html) (required) — The subnet in which the NAT gateway is located.
