feat: add Elastic IP for permanent domain pointing

This commit is contained in:
ikechukwu Elizabeth
2026-05-30 10:03:23 +01:00
parent 1aab587d9a
commit aec34b9c1e
2 changed files with 28 additions and 2 deletions
+16
View File
@@ -142,3 +142,19 @@ resource "aws_instance" "app" {
ignore_changes = [ami, user_data]
}
}
# --------------------------------------------------
# Elastic IP - permanent public IP for the EC2 instance.
# This IP never changes even after instance restarts,
# making it safe to point a domain name at it.
# --------------------------------------------------
resource "aws_eip" "app" {
domain = "vpc"
instance = aws_instance.app.id
tags = {
Name = "${var.project_name}-eip"
Project = var.project_name
Environment = var.environment
}
}
+11 -1
View File
@@ -14,7 +14,7 @@ output "private_subnet_id" {
}
output "ec2_instance_id" {
description = "EC2 instance ID — use this to connect via SSM"
description = "EC2 instance ID - use this to connect via SSM"
value = aws_instance.app.id
}
@@ -27,3 +27,13 @@ output "ec2_public_dns" {
description = "Public DNS of the EC2 instance"
value = aws_instance.app.public_dns
}
output "elastic_ip" {
description = "Permanent Elastic IP - point your domain DNS A record to this"
value = aws_eip.app.public_ip
}
output "rds_hostname" {
description = "RDS instance hostname"
value = aws_db_instance.tasks.address
}