Skip to main content

Elastic IP

πŸ“¦ Overview​

This Terraform module provisions a standalone Elastic IP (EIP) in AWS for resources requiring a fixed public IPv4 address.

It’s ideal for use with NAT gateways, bastion hosts, or any compute instance needing consistent public exposure.


βœ… Key Features​

  • Allocates a static public IPv4 address in a chosen region
  • Tags the EIP with Name, Environment, and other metadata
  • Can be used independently or integrated into composed stacks
  • Returns both the EIP address and allocation ID as outputs

πŸ’Ό Use Cases​

  • Assigning a static IP to bastion hosts for SSH access
  • Reserving an address for a NAT Gateway in a private subnet setup
  • Supporting allowlists in firewalls that require fixed IPs
  • Mapping DNS records to a consistent IP during CI/CD deployments

πŸ“₯ Input Variables​

NameTypeDescription
regionstringAWS region to deploy the Elastic IP
environmentstringTag to specify the deployment environment (e.g., dev, staging, prod)
namestringDescriptive tag for identifying the EIP

πŸ“€ Outputs​

NameDescription
eip_idThe ID of the created Elastic IP
eip_addressThe public IPv4 address assigned

πŸš€ Deployment Readiness​

  • βœ… Compatible with Terraform 1.0+
  • βœ… Tested with AWS provider 5.x
  • πŸ§ͺ Requires IAM permissions for ec2:AllocateAddress and ec2:DescribeAddresses

πŸ› οΈ Example Usage​

module "elastic_ip" {
source = "git::ssh://git@github.com/archiphire/aws-level-1-modules.git//network/elastic-ip?ref=v1.0.0"

region = "us-east-1"
environment = "prod"
name = "bastion-ip"
}
terraform init
terraform plan
terraform apply

or

tofu init
tofu plan
tofu apply

🧹 Cleanup Options​

Terraform Destroy (for test environments):

terraform destroy

or

tofu destroy

Manual Deletion (for production):

Release the Elastic IP manually in the AWS Console or via CLI:

aws ec2 release-address --allocation-id <eip_id>

πŸ›‘οΈ Notes​

This is a Level 1 networking module for provisioning static IPs. To associate this EIP with EC2 instances or NAT gateways, refer to the relevant module documentation for those resources.

πŸ”’ Deployment Package Notice​

This module is part of the Level 1 AWS License Tier. To access the full deployment package and source code, subscribe to Archiphire.