Skip to content
v2.277.0

Experimental

@aws-cdk/aws-ec2-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

InternetGatewayOptions Struct ​

Options to define InternetGateway for VPC.

Example ​

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
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
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());
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"
});
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 ​

internetGatewayNameoptionalstringinternet_gateway_nameoptionalstrinternetGatewayNameoptionalStringInternetGatewayNameoptionalstringInternetGatewayNameoptional*string#
The resource name of the internet gateway.

Default: provisioned without a resource name

Provided name will be used for tagging

ipv4Destinationoptionalstringipv4_destinationoptionalstripv4DestinationoptionalStringIpv4DestinationoptionalstringIpv4Destinationoptional*string#
Destination Ipv6 address for EGW route.

Default: '0.0.0.0' all Ipv4 traffic

ipv6Destinationoptionalstringipv6_destinationoptionalstripv6DestinationoptionalStringIpv6DestinationoptionalstringIpv6Destinationoptional*string#
Destination Ipv6 address for EGW route.

Default: '::/0' all Ipv6 traffic

subnetsoptionalSubnetSelection[]subnetsoptionaltyping.List[SubnetSelection]subnetsoptionalList<SubnetSelection>SubnetsoptionalSubnetSelection[]Subnetsoptional*[]SubnetSelection#
List of subnets where route to IGW will be added.

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