mirror of
https://github.com/Sea-Haven-Industries/file-share.git
synced 2026-10-02 07:13:15 +00:00
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.
36 lines
936 B
HCL
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
|
|
}
|