Skip to content
GitHubXDiscord

VPCDHCPOptionsAssociation

The VPCDHCPOptionsAssociation resource allows you to associate DHCP options with your Amazon Virtual Private Cloud (VPC). For more details, refer to the AWS EC2 VPCDHCPOptionsAssociations documentation.

This example demonstrates how to create a basic VPCDHCPOptionsAssociation with required properties.

import AWS from "alchemy/aws/control";
const dhcpOptionsAssociation = await AWS.EC2.VPCDHCPOptionsAssociation("defaultDhcpOptionsAssociation", {
VpcId: "vpc-0abcd1234efgh5678",
DhcpOptionsId: "dopt-0abcd1234efgh5678",
adopt: false // Default is false; this will fail if the resource already exists
});

This example shows how to create a VPCDHCPOptionsAssociation while adopting an existing resource.

const existingDhcpOptionsAssociation = await AWS.EC2.VPCDHCPOptionsAssociation("existingDhcpOptionsAssociation", {
VpcId: "vpc-0abcd1234efgh5678",
DhcpOptionsId: "dopt-0abcd1234efgh5678",
adopt: true // Set to true to adopt if the resource already exists
});

In this example, you can see how to update the DHCP options associated with a VPC by creating a new association.

const updatedDhcpOptionsAssociation = await AWS.EC2.VPCDHCPOptionsAssociation("updatedDhcpOptionsAssociation", {
VpcId: "vpc-0abcd1234efgh5678",
DhcpOptionsId: "dopt-0ijkl9012mnop3456",
adopt: false // This will create a new association
});