From a1c21b05eb76ef535d16e8a610002fc1a51e858c Mon Sep 17 00:00:00 2001 From: SteveLinden Date: Wed, 15 May 2024 08:45:55 +0100 Subject: [PATCH] Removed cooker code and reset the ecs.tf to remove commets --- terraform/environments/cooker/macie.tf | 25 ------ terraform/environments/example/data.tf | 13 --- terraform/environments/example/ecs.tf | 110 ++++++++++++------------- 3 files changed, 55 insertions(+), 93 deletions(-) delete mode 100644 terraform/environments/cooker/macie.tf diff --git a/terraform/environments/cooker/macie.tf b/terraform/environments/cooker/macie.tf deleted file mode 100644 index 47e99b6f4c5..00000000000 --- a/terraform/environments/cooker/macie.tf +++ /dev/null @@ -1,25 +0,0 @@ - -# Create macie account - -resource "aws_macie2_account" "cooker" { - finding_publishing_frequency = "ONE_HOUR" - status = "ENABLED" - } - -# Now create a job - -resource "aws_macie2_classification_job" "cooker" { - job_type = "ONE_TIME" - name = "JOBNAME" - s3_job_definition { - bucket_definitions { - account_id = local.environment_management.account_ids[terraform.workspace] - buckets = [ - data.aws_s3_bucket.bucket1.id, - data.aws_s3_bucket.bucket2.id, - data.aws_s3_bucket.bucket3.id, - ] - } - } - depends_on = [ aws_macie2_account.cooker ] -} \ No newline at end of file diff --git a/terraform/environments/example/data.tf b/terraform/environments/example/data.tf index b007551a6f6..96a2521d17e 100644 --- a/terraform/environments/example/data.tf +++ b/terraform/environments/example/data.tf @@ -1,14 +1 @@ #### This file can be used to store data specific to the member account #### - -# For macie code - data "aws_s3_bucket" "bucket1" { - bucket = "bastion-example-example-development-jxaebg" - } - - data "aws_s3_bucket" "bucket2" { - bucket = "config-20220505080423816000000003" - } - - data "aws_s3_bucket" "bucket3" { - bucket = "s3-bucket-example20240430100555519600000006" - } \ No newline at end of file diff --git a/terraform/environments/example/ecs.tf b/terraform/environments/example/ecs.tf index 0279e89d6d0..c7942f7e5df 100644 --- a/terraform/environments/example/ecs.tf +++ b/terraform/environments/example/ecs.tf @@ -3,61 +3,61 @@ ########################################################################################### -# module "ecs-cluster" { -# source = "github.com/ministryofjustice/modernisation-platform-terraform-ecs-cluster//cluster?ref=v4.0.3" - -# ec2_capacity_instance_type = local.application_data.accounts[local.environment].container_instance_type -# ec2_capacity_max_size = local.application_data.accounts[local.environment].ec2_max_size -# ec2_capacity_min_size = local.application_data.accounts[local.environment].ec2_min_size -# ec2_capacity_security_group_id = aws_security_group.cluster_ec2.id -# ec2_subnet_ids = [ -# data.aws_subnet.private_subnets_a.id, -# data.aws_subnet.private_subnets_b.id, -# data.aws_subnet.private_subnets_c.id -# ] -# environment = local.environment -# name = local.ecs_application_name -# namespace = "platforms" - -# tags = local.tags -# } - -# module "service" { -# source = "git::https://github.com/ministryofjustice/modernisation-platform-terraform-ecs-cluster//service?ref=v3.0.0" - -# container_definition_json = templatefile("${path.module}/templates/task_definition.json.tftpl", {}) -# ecs_cluster_arn = module.ecs-cluster.ecs_cluster_arn -# name = "${local.ecs_application_name}-task_definition_volume" -# namespace = "platforms" -# vpc_id = local.vpc_all - -# launch_type = local.application_data.accounts[local.environment].launch_type -# network_mode = local.application_data.accounts[local.environment].network_mode - -# task_cpu = local.application_data.accounts[local.environment].container_cpu -# task_memory = local.application_data.accounts[local.environment].container_memory - -# task_exec_role_arn = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${local.ecs_application_name}-ecs-task-execution-role" - -# environment = local.environment -# ecs_load_balancers = [ -# { -# target_group_arn = aws_lb_target_group.ecs_target_group.arn -# container_name = local.ecs_application_name -# container_port = 80 -# } -# ] - -# subnet_ids = [ -# data.aws_subnet.private_subnets_a.id, -# data.aws_subnet.private_subnets_b.id, -# data.aws_subnet.private_subnets_c.id -# ] - -# ignore_changes_task_definition = false - -# tags = local.tags -# } +module "ecs-cluster" { + source = "github.com/ministryofjustice/modernisation-platform-terraform-ecs-cluster//cluster?ref=v4.0.3" + + ec2_capacity_instance_type = local.application_data.accounts[local.environment].container_instance_type + ec2_capacity_max_size = local.application_data.accounts[local.environment].ec2_max_size + ec2_capacity_min_size = local.application_data.accounts[local.environment].ec2_min_size + ec2_capacity_security_group_id = aws_security_group.cluster_ec2.id + ec2_subnet_ids = [ + data.aws_subnet.private_subnets_a.id, + data.aws_subnet.private_subnets_b.id, + data.aws_subnet.private_subnets_c.id + ] + environment = local.environment + name = local.ecs_application_name + namespace = "platforms" + + tags = local.tags +} + +module "service" { + source = "git::https://github.com/ministryofjustice/modernisation-platform-terraform-ecs-cluster//service?ref=v3.0.0" + + container_definition_json = templatefile("${path.module}/templates/task_definition.json.tftpl", {}) + ecs_cluster_arn = module.ecs-cluster.ecs_cluster_arn + name = "${local.ecs_application_name}-task_definition_volume" + namespace = "platforms" + vpc_id = local.vpc_all + + launch_type = local.application_data.accounts[local.environment].launch_type + network_mode = local.application_data.accounts[local.environment].network_mode + + task_cpu = local.application_data.accounts[local.environment].container_cpu + task_memory = local.application_data.accounts[local.environment].container_memory + + task_exec_role_arn = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${local.ecs_application_name}-ecs-task-execution-role" + + environment = local.environment + ecs_load_balancers = [ + { + target_group_arn = aws_lb_target_group.ecs_target_group.arn + container_name = local.ecs_application_name + container_port = 80 + } + ] + + subnet_ids = [ + data.aws_subnet.private_subnets_a.id, + data.aws_subnet.private_subnets_b.id, + data.aws_subnet.private_subnets_c.id + ] + + ignore_changes_task_definition = false + + tags = local.tags +} locals { ecs_application_name = "example-app"