Skip to content
GitHubXDiscord

EIP

The EIP (Elastic IP) resource lets you manage AWS EC2 Elastic IPs for your cloud infrastructure.

Create a basic Elastic IP with an optional tag.

import AWS from "alchemy/aws/control";
const elasticIp = await AWS.EC2.EIP("myElasticIP", {
Tags: [
{
Key: "Name",
Value: "MyElasticIP"
}
]
});

Allocate an Elastic IP from a specific IP address pool and attach it to an EC2 instance.

import AWS from "alchemy/aws/control";
const instanceId = "i-0abcd1234efgh5678"; // Replace with your EC2 instance ID
const advancedElasticIp = await AWS.EC2.EIP("advancedElasticIP", {
InstanceId: instanceId,
PublicIpv4Pool: "my-public-ipv4-pool",
Tags: [
{
Key: "Environment",
Value: "Production"
}
]
});

Allocate an Elastic IP from an IPAM pool.

import AWS from "alchemy/aws/control";
const ipamPoolId = "ipam-pool-12345678"; // Replace with your IPAM pool ID
const ipamElasticIp = await AWS.EC2.EIP("ipamElasticIP", {
IpamPoolId: ipamPoolId,
Tags: [
{
Key: "Service",
Value: "WebServer"
}
]
});

Transfer an Elastic IP address to another AWS account.

import AWS from "alchemy/aws/control";
const transferElasticIp = await AWS.EC2.EIP("transferElasticIP", {
TransferAddress: "203.0.113.25", // Replace with the Elastic IP address to transfer
Tags: [
{
Key: "Transfer",
Value: "Pending"
}
]
});