InternetGateway
The InternetGateway resource allows you to manage AWS EC2 InternetGateways which are used to enable communication between instances in your Virtual Private Cloud (VPC) and the internet.
Minimal Example
Section titled “Minimal Example”Create a basic InternetGateway with a tag for identification.
import AWS from "alchemy/aws/control";
const internetGateway = await AWS.EC2.InternetGateway("myInternetGateway", { Tags: [ { Key: "Name", Value: "MyInternetGateway" } ]});
Advanced Configuration
Section titled “Advanced Configuration”Configure an InternetGateway to adopt an existing resource if it already exists.
const existingInternetGateway = await AWS.EC2.InternetGateway("existingGateway", { adopt: true, Tags: [ { Key: "Environment", Value: "Production" } ]});
Attach to a VPC
Section titled “Attach to a VPC”Demonstrate how to attach the InternetGateway to a VPC for internet access.
import AWS from "alchemy/aws/control";
const myVpc = await AWS.EC2.Vpc("myVpc", { CidrBlock: "10.0.0.0/16", Tags: [ { Key: "Name", Value: "MyVPC" } ]});
const internetGateway = await AWS.EC2.InternetGateway("vpcInternetGateway", { Tags: [ { Key: "Name", Value: "VPCInternetGateway" } ]});
// Attach the InternetGateway to the VPCawait AWS.EC2.AttachInternetGateway("attachGateway", { InternetGatewayId: internetGateway.id, VpcId: myVpc.id});
Detach from a VPC
Section titled “Detach from a VPC”Detach the InternetGateway from a VPC when no longer needed.
await AWS.EC2.DetachInternetGateway("detachGateway", { InternetGatewayId: internetGateway.id, VpcId: myVpc.id});