From 26c9fbb2b3b72142c671d4f8b598732b79f3f0dd Mon Sep 17 00:00:00 2001 From: Justin Terry Date: Mon, 1 Jul 2024 15:31:45 -0700 Subject: [PATCH 01/13] Add port to LB for service URI in dev --- terraform/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/main.tf b/terraform/main.tf index 92b41c23f..1cc27ede5 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -25,7 +25,7 @@ locals { project = "gfw-data-api" aurora_instance_class = data.terraform_remote_state.core.outputs.aurora_cluster_instance_class aurora_max_vcpus = local.aurora_instance_class == "db.t3.medium" ? 2 : local.aurora_instance_class == "db.r6g.large" ? 2 : local.aurora_instance_class == "db.r6g.xlarge" ? 4 : local.aurora_instance_class == "db.r6g.2xlarge" ? 8 : local.aurora_instance_class == "db.r6g.4xlarge" ? 16 : local.aurora_instance_class == "db.r6g.8xlarge" ? 32 : local.aurora_instance_class == "db.r6g.16xlarge" ? 64 : local.aurora_instance_class == "db.r5.large" ? 2 : local.aurora_instance_class == "db.r5.xlarge" ? 4 : local.aurora_instance_class == "db.r5.2xlarge" ? 8 : local.aurora_instance_class == "db.r5.4xlarge" ? 16 : local.aurora_instance_class == "db.r5.8xlarge" ? 32 : local.aurora_instance_class == "db.r5.12xlarge" ? 48 : local.aurora_instance_class == "db.r5.16xlarge" ? 64 : local.aurora_instance_class == "db.r5.24xlarge" ? 96 : "" - service_url = var.environment == "dev" ? "http://${module.fargate_autoscaling.lb_dns_name}" : var.service_url + service_url = var.environment == "dev" ? "http://${module.fargate_autoscaling.lb_dns_name}:${data.external.generate_port[0].result["port"]}" : var.service_url container_tag = substr(var.git_sha, 0, 7) lb_dns_name = coalesce(module.fargate_autoscaling.lb_dns_name, var.lb_dns_name) } From d852f43c1976b3ff07022d317b377e8c0bc96d2e Mon Sep 17 00:00:00 2001 From: Justin Terry Date: Tue, 2 Jul 2024 10:57:32 -0700 Subject: [PATCH 02/13] Use correc LB DNS name in dev for service uri --- terraform/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terraform/main.tf b/terraform/main.tf index 1cc27ede5..6a52e0179 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -25,9 +25,9 @@ locals { project = "gfw-data-api" aurora_instance_class = data.terraform_remote_state.core.outputs.aurora_cluster_instance_class aurora_max_vcpus = local.aurora_instance_class == "db.t3.medium" ? 2 : local.aurora_instance_class == "db.r6g.large" ? 2 : local.aurora_instance_class == "db.r6g.xlarge" ? 4 : local.aurora_instance_class == "db.r6g.2xlarge" ? 8 : local.aurora_instance_class == "db.r6g.4xlarge" ? 16 : local.aurora_instance_class == "db.r6g.8xlarge" ? 32 : local.aurora_instance_class == "db.r6g.16xlarge" ? 64 : local.aurora_instance_class == "db.r5.large" ? 2 : local.aurora_instance_class == "db.r5.xlarge" ? 4 : local.aurora_instance_class == "db.r5.2xlarge" ? 8 : local.aurora_instance_class == "db.r5.4xlarge" ? 16 : local.aurora_instance_class == "db.r5.8xlarge" ? 32 : local.aurora_instance_class == "db.r5.12xlarge" ? 48 : local.aurora_instance_class == "db.r5.16xlarge" ? 64 : local.aurora_instance_class == "db.r5.24xlarge" ? 96 : "" - service_url = var.environment == "dev" ? "http://${module.fargate_autoscaling.lb_dns_name}:${data.external.generate_port[0].result["port"]}" : var.service_url container_tag = substr(var.git_sha, 0, 7) lb_dns_name = coalesce(module.fargate_autoscaling.lb_dns_name, var.lb_dns_name) + service_url = var.environment == "dev" ? "http://${local.lb_dns_name}:${data.external.generate_port[0].result["port"]}" : var.service_url } # Docker image for FastAPI app From fd0afdf9830c57f58313b7d75f2812eed52e2215 Mon Sep 17 00:00:00 2001 From: Justin Terry Date: Tue, 2 Jul 2024 15:16:02 -0700 Subject: [PATCH 03/13] Set error messaging for reporting task status --- batch/scripts/report_status.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/batch/scripts/report_status.sh b/batch/scripts/report_status.sh index b8b779ccb..5d0f20ee4 100755 --- a/batch/scripts/report_status.sh +++ b/batch/scripts/report_status.sh @@ -73,6 +73,8 @@ generate_payload() EOF } +set -x + echo "$(generate_payload)" CTYPE_HEADER="Content-Type:application/json" From a7844214c9bf9a56047e43b23749412c3a16ed16 Mon Sep 17 00:00:00 2001 From: Justin Terry Date: Tue, 2 Jul 2024 15:17:59 -0700 Subject: [PATCH 04/13] Set error messaging for reporting task status --- batch/scripts/report_status.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/batch/scripts/report_status.sh b/batch/scripts/report_status.sh index 5d0f20ee4..49e0b1e48 100755 --- a/batch/scripts/report_status.sh +++ b/batch/scripts/report_status.sh @@ -78,7 +78,9 @@ set -x echo "$(generate_payload)" CTYPE_HEADER="Content-Type:application/json" -curl -s -X PATCH -H "${AUTH_HEADER}" -H "${CTYPE_HEADER}" -d "$(generate_payload)" "${URL}" +RESPONSE=$(curl -s -X PATCH -H "${AUTH_HEADER}" -H "${CTYPE_HEADER}" -d "$(generate_payload)" "${URL}") + +echo $RESPONSE # Try to clean up free space for potential other batch jobs on the same node set +e From 627421902dbfae4e82fa9f21d4258641afd2a99e Mon Sep 17 00:00:00 2001 From: Daniel Mannarino Date: Mon, 12 Aug 2024 14:21:40 -0400 Subject: [PATCH 05/13] Un-silence curl command in report status script --- batch/scripts/report_status.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/batch/scripts/report_status.sh b/batch/scripts/report_status.sh index 7f528a383..d636dff86 100755 --- a/batch/scripts/report_status.sh +++ b/batch/scripts/report_status.sh @@ -81,9 +81,7 @@ set -x echo "$(generate_payload)" CTYPE_HEADER="Content-Type:application/json" -RESPONSE=$(curl -s -X PATCH -H "${AUTH_HEADER}" -H "${CTYPE_HEADER}" -d "$(generate_payload)" "${URL}") - -echo $RESPONSE +curl -i -X PATCH -H "${AUTH_HEADER}" -H "${CTYPE_HEADER}" -d "$(generate_payload)" "${URL}" # Try to clean up free space for potential other batch jobs on the same node set +e From 04e9de23079022732cb7abfacbe043c0031a4cbb Mon Sep 17 00:00:00 2001 From: Daniel Mannarino Date: Sun, 25 Aug 2024 10:19:16 -0400 Subject: [PATCH 06/13] Use newer gfw-terraform-modules tag for new SGs --- terraform/main.tf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 0815e06c5..08a2a6238 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -32,7 +32,7 @@ locals { # Docker image for FastAPI app module "app_docker_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.3" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha" image_name = substr(lower("${local.project}${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" tag = local.container_tag @@ -40,7 +40,7 @@ module "app_docker_image" { # Docker image for GDAL Python Batch jobs module "batch_gdal_python_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.3" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha" image_name = substr(lower("${local.project}-gdal_python${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -49,7 +49,7 @@ module "batch_gdal_python_image" { # Docker image for PixETL Batch jobs module "batch_pixetl_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.3" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha" image_name = substr(lower("${local.project}-pixetl${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -58,7 +58,7 @@ module "batch_pixetl_image" { # Docker image for PostgreSQL Client Batch jobs module "batch_postgresql_client_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.3" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha" image_name = substr(lower("${local.project}-postgresql_client${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -67,7 +67,7 @@ module "batch_postgresql_client_image" { # Docker image for Tile Cache Batch jobs module "batch_tile_cache_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.3" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha" image_name = substr(lower("${local.project}-tile_cache${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -121,7 +121,7 @@ module "fargate_autoscaling" { # Using instance types with 1 core only module "batch_aurora_writer" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.3" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha" ecs_role_policy_arns = [ data.terraform_remote_state.core.outputs.iam_policy_s3_write_data-lake_arn, data.terraform_remote_state.core.outputs.secrets_postgresql-reader_policy_arn, @@ -152,7 +152,7 @@ module "batch_aurora_writer" { module "batch_data_lake_writer" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.3" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha" ecs_role_policy_arns = [ aws_iam_policy.query_batch_jobs.arn, aws_iam_policy.s3_read_only.arn, From d16816e46a0ae22478f781e6c0c54b575cc6c9b1 Mon Sep 17 00:00:00 2001 From: Daniel Mannarino Date: Tue, 27 Aug 2024 00:49:31 -0400 Subject: [PATCH 07/13] More SG work --- terraform/main.tf | 27 ++++++++++++++++----------- terraform/modules/batch/main.tf | 1 - 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 08a2a6238..e4911d66d 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -32,7 +32,7 @@ locals { # Docker image for FastAPI app module "app_docker_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha4" image_name = substr(lower("${local.project}${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" tag = local.container_tag @@ -40,7 +40,7 @@ module "app_docker_image" { # Docker image for GDAL Python Batch jobs module "batch_gdal_python_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha4" image_name = substr(lower("${local.project}-gdal_python${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -49,7 +49,7 @@ module "batch_gdal_python_image" { # Docker image for PixETL Batch jobs module "batch_pixetl_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha4" image_name = substr(lower("${local.project}-pixetl${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -58,7 +58,7 @@ module "batch_pixetl_image" { # Docker image for PostgreSQL Client Batch jobs module "batch_postgresql_client_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha4" image_name = substr(lower("${local.project}-postgresql_client${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -67,7 +67,7 @@ module "batch_postgresql_client_image" { # Docker image for Tile Cache Batch jobs module "batch_tile_cache_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha4" image_name = substr(lower("${local.project}-tile_cache${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -76,7 +76,7 @@ module "batch_tile_cache_image" { module "fargate_autoscaling" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/fargate_autoscaling?ref=v0.4.2.5" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/fargate_autoscaling?ref=v0.4.2.6-alpha4" project = local.project name_suffix = local.name_suffix tags = local.fargate_tags @@ -96,7 +96,10 @@ module "fargate_autoscaling" { auto_scaling_max_cpu_util = var.auto_scaling_max_cpu_util auto_scaling_min_capacity = var.auto_scaling_min_capacity // acm_certificate_arn = var.environment == "dev" ? null : data.terraform_remote_state.core.outputs.acm_certificate - security_group_ids = [data.terraform_remote_state.core.outputs.postgresql_security_group_id] + security_group_ids = [ + data.terraform_remote_state.core.outputs.postgresql_security_group_id, + data.terraform_remote_state.core.outputs.aws_security_group.ecs_security_group_id + ] task_role_policies = [ data.terraform_remote_state.core.outputs.iam_policy_s3_write_data-lake_arn, aws_iam_policy.run_batch_jobs.arn, @@ -121,7 +124,7 @@ module "fargate_autoscaling" { # Using instance types with 1 core only module "batch_aurora_writer" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha4" ecs_role_policy_arns = [ data.terraform_remote_state.core.outputs.iam_policy_s3_write_data-lake_arn, data.terraform_remote_state.core.outputs.secrets_postgresql-reader_policy_arn, @@ -140,7 +143,8 @@ module "batch_aurora_writer" { project = local.project security_group_ids = [ data.terraform_remote_state.core.outputs.default_security_group_id, - data.terraform_remote_state.core.outputs.postgresql_security_group_id + data.terraform_remote_state.core.outputs.postgresql_security_group_id, + data.terraform_remote_state.core.outputs.aws_security_group.batch_security_group_id ] subnets = data.terraform_remote_state.core.outputs.private_subnet_ids suffix = local.name_suffix @@ -152,7 +156,7 @@ module "batch_aurora_writer" { module "batch_data_lake_writer" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha4" ecs_role_policy_arns = [ aws_iam_policy.query_batch_jobs.arn, aws_iam_policy.s3_read_only.arn, @@ -167,7 +171,8 @@ module "batch_data_lake_writer" { project = local.project security_group_ids = [ data.terraform_remote_state.core.outputs.default_security_group_id, - data.terraform_remote_state.core.outputs.postgresql_security_group_id + data.terraform_remote_state.core.outputs.postgresql_security_group_id, + data.terraform_remote_state.core.outputs.aws_security_group.batch_security_group_id ] subnets = data.terraform_remote_state.core.outputs.private_subnet_ids suffix = local.name_suffix diff --git a/terraform/modules/batch/main.tf b/terraform/modules/batch/main.tf index 3433ccf4c..80aa9ce62 100644 --- a/terraform/modules/batch/main.tf +++ b/terraform/modules/batch/main.tf @@ -52,7 +52,6 @@ resource "aws_batch_job_queue" "pixetl" { depends_on = [var.pixetl_compute_environment_arn] } - resource "aws_batch_job_definition" "tile_cache" { name = substr("${var.project}-tile_cache${var.name_suffix}", 0, 64) type = "container" From da9c03aeab59e6d0f9a493af138a2b33b8099ca8 Mon Sep 17 00:00:00 2001 From: Daniel Mannarino Date: Tue, 27 Aug 2024 00:59:45 -0400 Subject: [PATCH 08/13] Fix refs to SGs --- terraform/main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index e4911d66d..a206d4013 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -98,7 +98,7 @@ module "fargate_autoscaling" { // acm_certificate_arn = var.environment == "dev" ? null : data.terraform_remote_state.core.outputs.acm_certificate security_group_ids = [ data.terraform_remote_state.core.outputs.postgresql_security_group_id, - data.terraform_remote_state.core.outputs.aws_security_group.ecs_security_group_id + data.terraform_remote_state.core.outputs.batch_security_group_id ] task_role_policies = [ data.terraform_remote_state.core.outputs.iam_policy_s3_write_data-lake_arn, @@ -144,7 +144,7 @@ module "batch_aurora_writer" { security_group_ids = [ data.terraform_remote_state.core.outputs.default_security_group_id, data.terraform_remote_state.core.outputs.postgresql_security_group_id, - data.terraform_remote_state.core.outputs.aws_security_group.batch_security_group_id + data.terraform_remote_state.core.outputs.batch_security_group_id ] subnets = data.terraform_remote_state.core.outputs.private_subnet_ids suffix = local.name_suffix @@ -172,7 +172,7 @@ module "batch_data_lake_writer" { security_group_ids = [ data.terraform_remote_state.core.outputs.default_security_group_id, data.terraform_remote_state.core.outputs.postgresql_security_group_id, - data.terraform_remote_state.core.outputs.aws_security_group.batch_security_group_id + data.terraform_remote_state.core.outputs.batch_security_group_id ] subnets = data.terraform_remote_state.core.outputs.private_subnet_ids suffix = local.name_suffix From d984f3766a686d993f567f72e1173634bf962743 Mon Sep 17 00:00:00 2001 From: Daniel Mannarino Date: Tue, 27 Aug 2024 01:14:41 -0400 Subject: [PATCH 09/13] Remove erroneous mention of batch sg --- terraform/main.tf | 1 - terraform/variables.tf | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index a206d4013..8db37671a 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -98,7 +98,6 @@ module "fargate_autoscaling" { // acm_certificate_arn = var.environment == "dev" ? null : data.terraform_remote_state.core.outputs.acm_certificate security_group_ids = [ data.terraform_remote_state.core.outputs.postgresql_security_group_id, - data.terraform_remote_state.core.outputs.batch_security_group_id ] task_role_policies = [ data.terraform_remote_state.core.outputs.iam_policy_s3_write_data-lake_arn, diff --git a/terraform/variables.tf b/terraform/variables.tf index 8b56728b9..f198e0835 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -95,7 +95,7 @@ variable "load_balancer_arn" { variable "load_balancer_security_group" { type = string default = "" - description = "Optional secuirty group of load balancer with which the task can communicate. Required if load_blancer_arn is not empty" + description = "Optional secuirty group of load balancer with which the task can communicate. Required if load_balancer_arn is not empty" } variable "listener_port" { From 22e397c4ff9c04b3b6ff9d07dd3197b7f2984ff4 Mon Sep 17 00:00:00 2001 From: Daniel Mannarino Date: Tue, 27 Aug 2024 01:35:34 -0400 Subject: [PATCH 10/13] Fix btch sg refs --- terraform/main.tf | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 8db37671a..ca3b957b7 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -32,7 +32,7 @@ locals { # Docker image for FastAPI app module "app_docker_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha4" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha5" image_name = substr(lower("${local.project}${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" tag = local.container_tag @@ -40,7 +40,7 @@ module "app_docker_image" { # Docker image for GDAL Python Batch jobs module "batch_gdal_python_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha4" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha5" image_name = substr(lower("${local.project}-gdal_python${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -49,7 +49,7 @@ module "batch_gdal_python_image" { # Docker image for PixETL Batch jobs module "batch_pixetl_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha4" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha5" image_name = substr(lower("${local.project}-pixetl${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -58,7 +58,7 @@ module "batch_pixetl_image" { # Docker image for PostgreSQL Client Batch jobs module "batch_postgresql_client_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha4" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha5" image_name = substr(lower("${local.project}-postgresql_client${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -67,7 +67,7 @@ module "batch_postgresql_client_image" { # Docker image for Tile Cache Batch jobs module "batch_tile_cache_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha4" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha5" image_name = substr(lower("${local.project}-tile_cache${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -76,7 +76,7 @@ module "batch_tile_cache_image" { module "fargate_autoscaling" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/fargate_autoscaling?ref=v0.4.2.6-alpha4" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/fargate_autoscaling?ref=v0.4.2.6-alpha5" project = local.project name_suffix = local.name_suffix tags = local.fargate_tags @@ -98,6 +98,7 @@ module "fargate_autoscaling" { // acm_certificate_arn = var.environment == "dev" ? null : data.terraform_remote_state.core.outputs.acm_certificate security_group_ids = [ data.terraform_remote_state.core.outputs.postgresql_security_group_id, + module.fargate_autoscaling.ecs_security_group_id ] task_role_policies = [ data.terraform_remote_state.core.outputs.iam_policy_s3_write_data-lake_arn, @@ -123,7 +124,7 @@ module "fargate_autoscaling" { # Using instance types with 1 core only module "batch_aurora_writer" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha4" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha5" ecs_role_policy_arns = [ data.terraform_remote_state.core.outputs.iam_policy_s3_write_data-lake_arn, data.terraform_remote_state.core.outputs.secrets_postgresql-reader_policy_arn, @@ -143,7 +144,7 @@ module "batch_aurora_writer" { security_group_ids = [ data.terraform_remote_state.core.outputs.default_security_group_id, data.terraform_remote_state.core.outputs.postgresql_security_group_id, - data.terraform_remote_state.core.outputs.batch_security_group_id + module.fargate_autoscaling.batch_security_group_id ] subnets = data.terraform_remote_state.core.outputs.private_subnet_ids suffix = local.name_suffix @@ -155,7 +156,7 @@ module "batch_aurora_writer" { module "batch_data_lake_writer" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha4" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha5" ecs_role_policy_arns = [ aws_iam_policy.query_batch_jobs.arn, aws_iam_policy.s3_read_only.arn, @@ -171,7 +172,7 @@ module "batch_data_lake_writer" { security_group_ids = [ data.terraform_remote_state.core.outputs.default_security_group_id, data.terraform_remote_state.core.outputs.postgresql_security_group_id, - data.terraform_remote_state.core.outputs.batch_security_group_id + module.fargate_autoscaling.batch_security_group_id ] subnets = data.terraform_remote_state.core.outputs.private_subnet_ids suffix = local.name_suffix From f01e074f3012d5be7716f0e98f50578336a6247b Mon Sep 17 00:00:00 2001 From: Daniel Mannarino Date: Thu, 29 Aug 2024 23:34:03 -0400 Subject: [PATCH 11/13] Fresh start with TF alpha8 --- Dockerfile | 2 +- terraform/main.tf | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index f6e52816b..f12240bd8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10-slim +FROM --platform=linux/amd64 tiangolo/uvicorn-gunicorn-fastapi:python3.10-slim # Optional build argument for different environments ARG ENV diff --git a/terraform/main.tf b/terraform/main.tf index ca3b957b7..05a894298 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -32,7 +32,7 @@ locals { # Docker image for FastAPI app module "app_docker_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha5" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha8" image_name = substr(lower("${local.project}${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" tag = local.container_tag @@ -40,7 +40,7 @@ module "app_docker_image" { # Docker image for GDAL Python Batch jobs module "batch_gdal_python_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha5" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha8" image_name = substr(lower("${local.project}-gdal_python${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -49,7 +49,7 @@ module "batch_gdal_python_image" { # Docker image for PixETL Batch jobs module "batch_pixetl_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha5" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha8" image_name = substr(lower("${local.project}-pixetl${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -58,7 +58,7 @@ module "batch_pixetl_image" { # Docker image for PostgreSQL Client Batch jobs module "batch_postgresql_client_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha5" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha8" image_name = substr(lower("${local.project}-postgresql_client${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -67,7 +67,7 @@ module "batch_postgresql_client_image" { # Docker image for Tile Cache Batch jobs module "batch_tile_cache_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha5" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha8" image_name = substr(lower("${local.project}-tile_cache${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -76,7 +76,7 @@ module "batch_tile_cache_image" { module "fargate_autoscaling" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/fargate_autoscaling?ref=v0.4.2.6-alpha5" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/fargate_autoscaling?ref=v0.4.2.6-alpha8" project = local.project name_suffix = local.name_suffix tags = local.fargate_tags @@ -124,7 +124,7 @@ module "fargate_autoscaling" { # Using instance types with 1 core only module "batch_aurora_writer" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha5" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha8" ecs_role_policy_arns = [ data.terraform_remote_state.core.outputs.iam_policy_s3_write_data-lake_arn, data.terraform_remote_state.core.outputs.secrets_postgresql-reader_policy_arn, @@ -156,7 +156,7 @@ module "batch_aurora_writer" { module "batch_data_lake_writer" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha5" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha8" ecs_role_policy_arns = [ aws_iam_policy.query_batch_jobs.arn, aws_iam_policy.s3_read_only.arn, From 22c1aef8cba0de0bfd59a99ad1f21e19a5b57edd Mon Sep 17 00:00:00 2001 From: Daniel Mannarino Date: Thu, 29 Aug 2024 23:43:14 -0400 Subject: [PATCH 12/13] Bump TF for minor fix --- terraform/main.tf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 05a894298..3bb9048ad 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -32,7 +32,7 @@ locals { # Docker image for FastAPI app module "app_docker_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha8" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha9" image_name = substr(lower("${local.project}${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" tag = local.container_tag @@ -40,7 +40,7 @@ module "app_docker_image" { # Docker image for GDAL Python Batch jobs module "batch_gdal_python_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha8" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha9" image_name = substr(lower("${local.project}-gdal_python${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -49,7 +49,7 @@ module "batch_gdal_python_image" { # Docker image for PixETL Batch jobs module "batch_pixetl_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha8" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha9" image_name = substr(lower("${local.project}-pixetl${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -58,7 +58,7 @@ module "batch_pixetl_image" { # Docker image for PostgreSQL Client Batch jobs module "batch_postgresql_client_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha8" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha9" image_name = substr(lower("${local.project}-postgresql_client${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -67,7 +67,7 @@ module "batch_postgresql_client_image" { # Docker image for Tile Cache Batch jobs module "batch_tile_cache_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha8" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha9" image_name = substr(lower("${local.project}-tile_cache${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -76,7 +76,7 @@ module "batch_tile_cache_image" { module "fargate_autoscaling" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/fargate_autoscaling?ref=v0.4.2.6-alpha8" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/fargate_autoscaling?ref=v0.4.2.6-alpha9" project = local.project name_suffix = local.name_suffix tags = local.fargate_tags @@ -124,7 +124,7 @@ module "fargate_autoscaling" { # Using instance types with 1 core only module "batch_aurora_writer" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha8" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha9" ecs_role_policy_arns = [ data.terraform_remote_state.core.outputs.iam_policy_s3_write_data-lake_arn, data.terraform_remote_state.core.outputs.secrets_postgresql-reader_policy_arn, @@ -156,7 +156,7 @@ module "batch_aurora_writer" { module "batch_data_lake_writer" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha8" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha9" ecs_role_policy_arns = [ aws_iam_policy.query_batch_jobs.arn, aws_iam_policy.s3_read_only.arn, From ddde5d203b8928f0ecdcb3cb8223448e8a3f5889 Mon Sep 17 00:00:00 2001 From: Daniel Mannarino Date: Fri, 30 Aug 2024 17:00:36 -0400 Subject: [PATCH 13/13] Fix TF tag --- terraform/main.tf | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 3bb9048ad..75901490f 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -1,4 +1,3 @@ -# Require TF version to be same as or greater than 0.12.24 terraform { backend "s3" { region = "us-east-1" @@ -32,7 +31,7 @@ locals { # Docker image for FastAPI app module "app_docker_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha9" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.7" image_name = substr(lower("${local.project}${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" tag = local.container_tag @@ -40,7 +39,7 @@ module "app_docker_image" { # Docker image for GDAL Python Batch jobs module "batch_gdal_python_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha9" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.7" image_name = substr(lower("${local.project}-gdal_python${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -49,7 +48,7 @@ module "batch_gdal_python_image" { # Docker image for PixETL Batch jobs module "batch_pixetl_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha9" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.7" image_name = substr(lower("${local.project}-pixetl${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -58,7 +57,7 @@ module "batch_pixetl_image" { # Docker image for PostgreSQL Client Batch jobs module "batch_postgresql_client_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha9" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.7" image_name = substr(lower("${local.project}-postgresql_client${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -67,7 +66,7 @@ module "batch_postgresql_client_image" { # Docker image for Tile Cache Batch jobs module "batch_tile_cache_image" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.6-alpha9" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/container_registry?ref=v0.4.2.7" image_name = substr(lower("${local.project}-tile_cache${local.name_suffix}"), 0, 64) root_dir = "${path.root}/../" docker_path = "batch" @@ -76,7 +75,7 @@ module "batch_tile_cache_image" { module "fargate_autoscaling" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/fargate_autoscaling?ref=v0.4.2.6-alpha9" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/fargate_autoscaling?ref=v0.4.2.7" project = local.project name_suffix = local.name_suffix tags = local.fargate_tags @@ -124,7 +123,7 @@ module "fargate_autoscaling" { # Using instance types with 1 core only module "batch_aurora_writer" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha9" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.7" ecs_role_policy_arns = [ data.terraform_remote_state.core.outputs.iam_policy_s3_write_data-lake_arn, data.terraform_remote_state.core.outputs.secrets_postgresql-reader_policy_arn, @@ -156,7 +155,7 @@ module "batch_aurora_writer" { module "batch_data_lake_writer" { - source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.6-alpha9" + source = "git::https://github.com/wri/gfw-terraform-modules.git//terraform/modules/compute_environment?ref=v0.4.2.7" ecs_role_policy_arns = [ aws_iam_policy.query_batch_jobs.arn, aws_iam_policy.s3_read_only.arn,