Skip to content
GitHubXDiscord

RouteServerAssociation

The RouteServerAssociation resource allows you to manage associations between a Route Server and a VPC within AWS EC2. This resource is essential for enabling dynamic routing capabilities in your network. For more details, visit the AWS EC2 RouteServerAssociations documentation.

This example demonstrates how to create a basic RouteServerAssociation with required properties and an optional adoption flag.

import AWS from "alchemy/aws/control";
const routeServerAssociation = await AWS.EC2.RouteServerAssociation("myRouteServerAssociation", {
VpcId: "vpc-0abcd1234efgh5678",
RouteServerId: "rs-0abcd1234efgh5678",
adopt: true // Optional: Adopt existing resource if it already exists
});

Here, we configure a RouteServerAssociation with just the essential properties, demonstrating how to create an association without optional parameters.

const advancedRouteServerAssociation = await AWS.EC2.RouteServerAssociation("advancedRouteServerAssociation", {
VpcId: "vpc-0abcd1234efgh5678",
RouteServerId: "rs-0abcd1234efgh5678"
});

In this example, we update an existing RouteServerAssociation by changing the RouteServerId.

const updatedRouteServerAssociation = await AWS.EC2.RouteServerAssociation("updatedRouteServerAssociation", {
VpcId: "vpc-0abcd1234efgh5678",
RouteServerId: "rs-0abcd1234efgh5678", // New Route Server ID
adopt: true
});

This example shows how to remove a RouteServerAssociation, demonstrating proper resource cleanup.

await AWS.EC2.RouteServerAssociation("deleteRouteServerAssociation", {
VpcId: "vpc-0abcd1234efgh5678",
RouteServerId: "rs-0abcd1234efgh5678",
adopt: false // Ensure this does not adopt an existing resource
});