Terraform 1.4.3: scenarios with Multi-Region Deployment of ECS Fargate Services Using Module Outputs
I've spent hours debugging this and Hey everyone, I'm running into an issue that's driving me crazy... I keep running into I'm working with scenarios when trying to deploy an Amazon ECS Fargate service across multiple regions using Terraform 1.4.3. I have created a reusable module for my ECS setup, but when I attempt to reference the output values from the module to create services in different regions, I'm working with unexpected behaviors. Here's a simplified version of the module I created: ```hcl module "ecs_service" { source = "./modules/ecs_service" cluster_name = var.cluster_name service_name = var.service_name desired_count = var.desired_count region = var.region } ``` In the root module, I call this module for both `us-east-1` and `us-west-2` like so: ```hcl provider "aws" { region = "us-east-1" } module "ecs_service_east" { source = "./modules/ecs_service" cluster_name = "my-cluster" service_name = "my-service-east" desired_count = 2 region = "us-east-1" } provider "aws" { alias = "west" region = "us-west-2" } module "ecs_service_west" { source = "./modules/ecs_service" providers = { aws = aws.west } cluster_name = "my-cluster" service_name = "my-service-west" desired_count = 2 region = "us-west-2" } ``` However, when I run `terraform apply`, I receive this behavior: ``` behavior: Invalid function argument on modules/ecs_service/main.tf line 20, in resource "aws_ecs_service" "this": 20: task_definition = module.ecs_task_definitions.arn Invalid value for "task_definition": want to parse ARN: Invalid ARN specified. ``` I've double-checked my module output configuration and ensured that the task definitions are created before the ECS service is being referenced. I've also tried to add explicit dependencies but nothing seems to work. Has anyone experienced similar issues when deploying ECS services across multiple regions with shared outputs? Whatβs the best way to reference outputs from a module in such a setup to avoid this question? Thanks in advance! This is happening in both development and production on Debian. Any feedback is welcome! I'm working on a desktop app that needs to handle this. Is this even possible?