file-share/terraform/ec2.tf
Adam Moussa 7cb3f6510f
feat(infra): add HCP Terraform for the prod file share (PLAT-77)
The prod host will live on a subnet in the syslog VPC. The data volume stays unmanaged and is attached only after a snapshot copy.
2026-09-28 16:38:03 -04:00

36 lines
936 B
HCL

resource "aws_instance" "this" {
count = local.create_instance ? 1 : 0
ami = var.ami_id
instance_type = "t4g.small"
subnet_id = aws_subnet.file_share.id
vpc_security_group_ids = [aws_security_group.file_share.id]
iam_instance_profile = aws_iam_instance_profile.this.name
associate_public_ip_address = true
user_data = local.user_data
user_data_replace_on_change = false
root_block_device {
volume_size = 20
volume_type = "gp3"
encrypted = true
}
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
}
tags = {
Name = "file-share"
"file-share-backup" = "true"
}
}
resource "aws_volume_attachment" "data" {
count = local.create_instance ? 1 : 0
device_name = "/dev/xvdf"
volume_id = var.data_volume_id
instance_id = aws_instance.this[0].id
}