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

Options to define InternetGateway for VPC.

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/vpc-v2-base.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2-base.ts#L81)

## Example

TypeScript:

```ts
const stack = new Stack();
const myVpc = new VpcV2(this, 'Vpc');

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({
  ipv4Destination: '192.168.0.0/16',
});
```

Python:

```python
stack = Stack()
my_vpc = VpcV2(self, "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(
    ipv4_destination="192.168.0.0/16"
)
```

Java:

```java
Stack stack = new Stack();
VpcV2 myVpc = new VpcV2(this, "Vpc");

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(InternetGatewayOptions.builder()
        .ipv4Destination("192.168.0.0/16")
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.ec2.Alpha
var stack = new Stack();
var myVpc = new VpcV2(this, "Vpc");

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(new InternetGatewayOptions {
    Ipv4Destination = "192.168.0.0/16"
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsec2alpha/v2
stack := awscdk.Newstack()
myVpc := awsec2alpha.NewVpcV2(this, jsii.String("Vpc"))

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(&InternetGatewayOptions{
	Ipv4Destination: jsii.String("192.168.0.0/16"),
})
```

## Properties

- `internetGatewayName`: string — The resource name of the internet gateway.

  **Default:** provisioned without a resource name

  Provided name will be used for tagging

- `ipv4Destination`: string — Destination Ipv6 address for EGW route.

  **Default:** '0.0.0.0' all Ipv4 traffic

- `ipv6Destination`: string — Destination Ipv6 address for EGW route.

  **Default:** '::/0' all Ipv6 traffic

- `subnets`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html)[] — List of subnets where route to IGW will be added.

  **Default:** route created for all subnets with Type `SubnetType.Public`
