Skip to main content
Knowledge Base

ECS Fargate provider confguration errors during terraform init

Answer

I'm using ECS Fargate modules. When running **`terraform init`**, I get this error. ``` Downloading git::git@github.com:gruntwork-io/terraform-aws-service-catalog.git?ref=v0.73.2 for fargate_cluster... - fargate_cluster in .terraform/modules/fargate_cluster/modules/services/ecs-fargate-cluster There are some problems with the configuration, described below. The Terraform configuration must be valid before initialization so that Terraform can determine which modules and providers need to be installed. ╷ │ Error: Module module.fargate_service.module.route53_health_check contains provider configuration │ │ Providers cannot be configured within modules using count, for_each or depends_on. ``` ╵Terraform v1.0.11 I'm using: ``` module "fargate_cluster" { source = "git::git@github.com:gruntwork-io/terraform-aws-service-catalog.git//modules/services/ecs-fargate-cluster?ref=v0.73.2" ... } module "fargate_service" { source = "git::git@github.com:gruntwork-io/terraform-aws-service-catalog.git//modules/services/ecs-service?ref=v0.73.2" ... } ``` In case this might be related to the Terraform AWS provider v4.0.0, my `.terraform.lock.hcl` file ``` provider "[registry.terraform.io/hashicorp/aws](http://registry.terraform.io/hashicorp/aws)" { version = "3.74.1" constraints = ">= 2.6.0, >= 2.68.0, ~> 3.23, >= 3.27.0" hashes = [ ``` How do I get past this error?

@KOConchobhair The issue is that the provider is being specified in the monitoring module, so the modules that use that cannot specify `depends_on`. We need to remove nested providers. We shouldn't [specify the provider here](https://github.com/gruntwork-io/terraform-aws-monitoring/blob/3c8d171/modules/alarms/route53-health-check-alarms/main.tf#L18-L30). I've [filed an issue](https://github.com/gruntwork-io/terraform-aws-monitoring/issues/244) for this. I think the workaround of removing `depends_on` is reasonable. The `fargate_service` depends on the outputs from `fargate_cluster` within the configuration, so Terraform will figure out that dependency and apply the cluster before the service.