Hey, when creating a Batch compute environment in AWS, an ECS cluster is being created as well. But, while the compute environment resource will be managed by Terraform, that ECS cluster won’t be.
That was leading me to an issue, regarding how can I control the settings of this ECS cluster, when this resource is not managed by Terraform.
The only solution I found was to import this resource and link it to a new resource in my Terraform configuration. I had to follow this steps:
- Add the Cluster resource in my Terraform configuration
resource "aws_ecs_cluster" "batch-cluster" {
name = "AWSBatch-cluster..."
setting {
name = "containerInsights"
value = true
}
}
-
Import the actual AWS cluster resource and link it to the resource which was just configured
terraform import aws_ecs_cluster.batch-cluster AWSBatch-cluster...
-
Apply and let the new setting take place.
terraform apply
This solution definitely worked, and I know this might be the only solution, but asking here just in case I missed a simpler or an easier solution.
Thanks