Skip to content
GitHubXDiscord

VPCBlockPublicAccessOptions

The VPCBlockPublicAccessOptions resource allows you to manage the public access settings for your Amazon EC2 VPCs. This resource helps ensure that your VPCs are configured to block public access as per your security requirements. For more information, refer to the AWS EC2 VPCBlockPublicAccessOptions documentation.

Create a basic VPCBlockPublicAccessOptions resource with the required properties.

import AWS from "alchemy/aws/control";
const vpcOptions = await AWS.EC2.VPCBlockPublicAccessOptions("vpcBlockPublicAccessOptions", {
InternetGatewayBlockMode: "block", // Set to 'block' or 'allow'
adopt: false // Default is false: does not adopt existing resources
});

Configure a VPCBlockPublicAccessOptions resource with an existing resource adoption.

const existingVpcOptions = await AWS.EC2.VPCBlockPublicAccessOptions("existingVpcBlockPublicAccessOptions", {
InternetGatewayBlockMode: "allow", // Allow public access through the internet gateway
adopt: true // Adopt existing resource if it already exists
});

Specific Use Case: Enforcing Block Public Access

Section titled “Specific Use Case: Enforcing Block Public Access”

Set up a VPCBlockPublicAccessOptions resource to enforce stricter security by blocking all public access.

const secureVpcOptions = await AWS.EC2.VPCBlockPublicAccessOptions("secureVpcBlockPublicAccessOptions", {
InternetGatewayBlockMode: "block", // Block all public access
adopt: false // Ensure it's a new resource, not adopting
});

Specific Use Case: Allowing Select Public Access

Section titled “Specific Use Case: Allowing Select Public Access”

Create a VPCBlockPublicAccessOptions resource that allows certain configurations for public access.

const selectiveVpcOptions = await AWS.EC2.VPCBlockPublicAccessOptions("selectiveVpcBlockPublicAccessOptions", {
InternetGatewayBlockMode: "allow", // Allow public access through the internet gateway
adopt: true // Adopt existing configurations if available
});