From 01edce17090756309725645571a4ab1efd308d3f Mon Sep 17 00:00:00 2001 From: mohit Date: Mon, 25 Mar 2024 11:04:44 +0000 Subject: [PATCH] makign changes for aws-batch --- .github/workflows/build-infra.yml | 2 +- infrastructure/batch.tf | 26 ++++++++++++++++++++++++++ infrastructure/data.tf | 8 ++++++-- infrastructure/ecr.tf | 8 +++++++- infrastructure/ecs.tf | 5 ++--- 5 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 infrastructure/batch.tf diff --git a/.github/workflows/build-infra.yml b/.github/workflows/build-infra.yml index 3bb6cdc2..e78bd4d7 100644 --- a/.github/workflows/build-infra.yml +++ b/.github/workflows/build-infra.yml @@ -3,7 +3,7 @@ name: build-infrastructure on: push: branches: - - feature/integrate_actions + - main jobs: set-vars: diff --git a/infrastructure/batch.tf b/infrastructure/batch.tf new file mode 100644 index 00000000..3ae8627b --- /dev/null +++ b/infrastructure/batch.tf @@ -0,0 +1,26 @@ + + +module "batch_compute" { + source = "../../i-ai-core-infrastructure/modules/batch/batch_compute_environment/" + project = "i-dot-ai" + name = "consultations" + region = var.region + vpc_id = data.terraform_remote_state.vpc.outputs.vpc_id + desired_vcpus = 0 + min_vcpus = 0 + max_vcpus = 20 + private_subnets = data.terraform_remote_state.vpc.outputs.private_subnets + state_bucket = var.state_bucket + +} + +module "batch_job_defintiion" { + source = "../../i-ai-core-infrastructure/modules/batch/batch_job_definitons/" + project = "i-dot-ai" + name = "consultations" + region = var.region + compute_environment_arn = module.batch_compute.compute_environment_arn + state_bucket = var.state_bucket + image = module.ecr_back_end.repository_url + fargate_flag = false +} diff --git a/infrastructure/data.tf b/infrastructure/data.tf index 6ac3b7e1..47c0c398 100644 --- a/infrastructure/data.tf +++ b/infrastructure/data.tf @@ -1,6 +1,10 @@ locals { - record_prefix = var.env == "prod" ? var.project_name : "${var.project_name}-${var.env}" - host = terraform.workspace == "prod" ? "${var.project_name}.ai.cabinetoffice.gov.uk" : "${var.project_name}-${terraform.workspace}.ai.cabinetoffice.gov.uk" + record_prefix = var.env == "prod" ? var.project_name : "${var.project_name}-${var.env}" + host = terraform.workspace == "prod" ? "${var.project_name}.ai.cabinetoffice.gov.uk" : "${var.project_name}-${terraform.workspace}.ai.cabinetoffice.gov.uk" + image_tag_frontend_test = "a07a0d03cfd1aeebf6baed86b7dccf4d79504405" + + image_frontend = + } data "terraform_remote_state" "vpc" { diff --git a/infrastructure/ecr.tf b/infrastructure/ecr.tf index 20f2a73f..7a7bc491 100644 --- a/infrastructure/ecr.tf +++ b/infrastructure/ecr.tf @@ -1,7 +1,13 @@ -module "ecr" { +module "ecr_front_end" { source = "../../i-ai-core-infrastructure//modules/ecr" project_name_prefix = var.project_name container_name = "front-end" } + +module "ecr_back_end" { + source = "../../i-ai-core-infrastructure//modules/ecr" + project_name_prefix = var.project_name + container_name = "pre-processing" +} diff --git a/infrastructure/ecs.tf b/infrastructure/ecs.tf index 028b4e7e..9a767aff 100644 --- a/infrastructure/ecs.tf +++ b/infrastructure/ecs.tf @@ -3,8 +3,8 @@ module "ecs" { project_name = var.project_name image_tag = "a07a0d03cfd1aeebf6baed86b7dccf4d79504405" prefix = "i-dot-ai" - ecr_repository_uri = var.ecr_repository_uri - ecs_cluster_id = data.terraform_remote_state.platform.outputs.ecs_cluster_id + ecr_repository_uri = module.ecr_front_end.repository_url + cluster_name = data.terraform_remote_state.platform.outputs.ecs_cluster_id health_check = { healthy_threshold = 3 unhealthy_threshold = 3 @@ -19,7 +19,6 @@ module "ecs" { container_port = "80" load_balancer_security_group = data.terraform_remote_state.platform.outputs.load_balancer_security_group_id["default"] aws_lb_arn = data.terraform_remote_state.platform.outputs.load_balancer_arn["default"] - host = local.host }