# AddNatGatewayOptions

Options for adding a NAT gateway to a public subnet.

Used as argument in: [PublicSubnet.addNatGateway](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.PublicSubnet.html#addnatgateway)

- Source: [`aws-ec2/lib/vpc.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-ec2/lib/vpc.ts#L2599)
- Type last changed: v2.272.0 · 30 Sep 2026

## Example

TypeScript:

```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';
const addNatGatewayOptions: ec2.AddNatGatewayOptions = {
  maxDrainDuration: cdk.Duration.minutes(30),
};
```

Python:

```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

add_nat_gateway_options = ec2.AddNatGatewayOptions(
    max_drain_duration=cdk.Duration.minutes(30)
)
```

Java:

```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.*;

AddNatGatewayOptions addNatGatewayOptions = AddNatGatewayOptions.builder()
        .maxDrainDuration(Duration.minutes(30))
        .build();
```

C# / .NET:

```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;

var addNatGatewayOptions = new AddNatGatewayOptions {
    MaxDrainDuration = Duration.Minutes(30)
};
```

Golang:

```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"

addNatGatewayOptions := &AddNatGatewayOptions{
	MaxDrainDuration: cdk.Duration_Minutes(jsii.Number(30)),
}
```

## Properties

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