tf-cf-aws-3tier-dev/terraform/compute.tf

31 lines
746 B
Terraform
Raw Normal View History

2023-06-19 12:40:53 -04:00
module "ec2_ssh_key" {
source = "terraform-aws-modules/key-pair/aws"
key_name = join("-", [var.tags.builder, var.tags.project, var.tags.environment])
public_key = var.ssh_public_key
tags = var.tags
}
module "standalone_ec2" {
for_each = var.ec2_template[*]
source = "terraform-aws-modules/ec2-instance/aws"
name = each.value["hostname"]
ami = each.value["ami"]
instance_type = each.value["family"]
key_name = module.ec2_ssh_key.key_pair_name
monitoring = true
vpc_security_group_ids = [module.ec2_rdp_sg.security_group_id]
subnet_id = each.value["subnet"]
root_block_device = [
{
volume_size = each.value["disksize"]
encrypted = true
}
]
tags = var.tags
}