diff --git a/terraform/environments/apex/ec2.tf b/terraform/environments/apex/ec2.tf index ba3a46d6db0..78bf40179d2 100644 --- a/terraform/environments/apex/ec2.tf +++ b/terraform/environments/apex/ec2.tf @@ -12,6 +12,11 @@ # EOF # } +resource "template_file" "web-userdata" { + filename = "run.sh" +} + + resource "aws_instance" "apex_db_instance" { ami = local.application_data.accounts[local.environment].ec2amiid associate_public_ip_address = false @@ -22,7 +27,8 @@ resource "aws_instance" "apex_db_instance" { monitoring = true subnet_id = data.aws_subnet.private_subnets_a.id iam_instance_profile = aws_iam_instance_profile.ec2_instance_profile.id - user_data = "${file("run.sh")}" + user_data = "${template_file.web-userdata.rendered}" + root_block_device { delete_on_termination = false @@ -47,6 +53,7 @@ data "local_file" "cloudwatch_agent" { filename = "${path.module}/cloudwatch_agent_config.json" } + resource "aws_security_group" "ec2" { name = local.application_name description = "APEX DB Server Security Group"