From c999ad6112fdd98416369d4ae8dfc54843674c9f Mon Sep 17 00:00:00 2001 From: matt-k1998 Date: Tue, 17 Dec 2024 15:41:47 +0000 Subject: [PATCH] Tribunals: recreate backup ec2 --- .../environments/tribunals/asg-shared.tf | 102 +++++++++--------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/terraform/environments/tribunals/asg-shared.tf b/terraform/environments/tribunals/asg-shared.tf index 98861cc1025..b6eaf67cef0 100644 --- a/terraform/environments/tribunals/asg-shared.tf +++ b/terraform/environments/tribunals/asg-shared.tf @@ -197,45 +197,45 @@ resource "aws_launch_template" "tribunals-all-lt" { user_data = filebase64("ec2-shared-user-data.sh") } -# resource "aws_launch_template" "tribunals-backup-lt" { -# name_prefix = "tribunals-backup" -# image_id = jsondecode(data.aws_ssm_parameter.ecs_optimized_ami.value)["image_id"] -# instance_type = "m5.4xlarge" -# update_default_version = true - -# iam_instance_profile { -# name = aws_iam_instance_profile.ec2_instance_profile.name -# } - -# block_device_mappings { -# device_name = "/dev/sda1" - -# ebs { -# volume_size = 80 -# volume_type = "gp2" -# } -# } -# ebs_optimized = true - -# network_interfaces { -# device_index = 0 -# security_groups = [aws_security_group.cluster_ec2.id] -# subnet_id = data.aws_subnets.shared-public.ids[1] -# delete_on_termination = true -# associate_public_ip_address = true -# } - -# tag_specifications { -# resource_type = "instance" -# tags = { -# Environment = local.environment -# Name = "tribunals-backup-instance" -# Role = "Backup" -# } -# } - -# user_data = filebase64("ec2-backup-instance-user-data.sh") -# } +resource "aws_launch_template" "tribunals-backup-lt" { + name_prefix = "tribunals-backup" + image_id = jsondecode(data.aws_ssm_parameter.ecs_optimized_ami.value)["image_id"] + instance_type = "m5.4xlarge" + update_default_version = true + + iam_instance_profile { + name = aws_iam_instance_profile.ec2_instance_profile.name + } + + block_device_mappings { + device_name = "/dev/sda1" + + ebs { + volume_size = 80 + volume_type = "gp2" + } + } + ebs_optimized = true + + network_interfaces { + device_index = 0 + security_groups = [aws_security_group.cluster_ec2.id] + subnet_id = data.aws_subnets.shared-public.ids[1] + delete_on_termination = true + associate_public_ip_address = true + } + + tag_specifications { + resource_type = "instance" + tags = { + Environment = local.environment + Name = "tribunals-backup-instance" + Role = "Backup" + } + } + + user_data = filebase64("ec2-backup-instance-user-data.sh") +} # # Finally, create the Auto scaling group for the launch template resource "aws_autoscaling_group" "tribunals-all-asg" { @@ -257,18 +257,18 @@ resource "aws_autoscaling_group" "tribunals-all-asg" { } } -# resource "aws_instance" "tribunals_backup" { -# launch_template { -# id = aws_launch_template.tribunals-backup-lt.id -# version = "$Latest" -# } - -# tags = { -# Environment = local.environment -# Name = "tribunals-backup-instance" -# Role = "Backup" -# } -# } +resource "aws_instance" "tribunals_backup" { + launch_template { + id = aws_launch_template.tribunals-backup-lt.id + version = "$Latest" + } + + tags = { + Environment = local.environment + Name = "tribunals-backup-instance" + Role = "Backup" + } +} ###########################################################################