Skip to content
GitHubXDiscordRSS

PrefixList

Learn how to create, update, and manage AWS EC2 PrefixLists using Alchemy Cloud Control.

The PrefixList resource allows you to manage AWS EC2 PrefixLists that are used to specify a list of IP address ranges. This is useful for simplifying security group and route table configurations.

Create a basic PrefixList with required properties and a common optional property.

import AWS from "alchemy/aws/control";
const prefixList = await AWS.EC2.PrefixList("myPrefixList", {
PrefixListName: "MyPrefixList",
AddressFamily: "IPv4",
MaxEntries: 100
});

Configure a PrefixList with entries and tags for better organization.

const advancedPrefixList = await AWS.EC2.PrefixList("advancedPrefixList", {
PrefixListName: "AdvancedPrefixList",
AddressFamily: "IPv4",
MaxEntries: 50,
Entries: [
{
Cidr: "10.0.0.0/24",
Description: "Office Network"
},
{
Cidr: "192.168.1.0/24",
Description: "Home Network"
}
],
Tags: [
{
Key: "Environment",
Value: "Development"
},
{
Key: "Project",
Value: "Alpha"
}
]
});

Create a PrefixList that includes multiple CIDR blocks for different environments.

const multiCidrPrefixList = await AWS.EC2.PrefixList("multiCidrPrefixList", {
PrefixListName: "MultiCIDRPrefixList",
AddressFamily: "IPv4",
Entries: [
{
Cidr: "172.16.0.0/16",
Description: "Corporate Network"
},
{
Cidr: "10.1.1.0/24",
Description: "Testing Network"
}
]
});

If you want to adopt an existing PrefixList instead of creating a new one, you can set the adopt property to true.

const adoptExistingPrefixList = await AWS.EC2.PrefixList("existingPrefixList", {
PrefixListName: "ExistingPrefixList",
AddressFamily: "IPv4",
adopt: true
});