I have an AWS Batch compute environment defined in my Terraform files. The creation of the compute environment creates an ECS Cluster, where the containers are being run.
The issue I have with Terraform, is that while the aws_batch_compute_environment
resource is managed by Terraform, then the aws_ecs_cluster
which is created from it is not.
I want to enable ContainerInsights on this cluster, but because it is not managed I am struggling to understand how to do it.
This is how my Batch compute environment is currently defined:
resource "aws_batch_compute_environment" "fargate-batch-compute" {
compute_environment_name = "fargate-batch-compute"
compute_resources {
max_vcpus = 100
security_group_ids = [...]
subnets = [...]
type = "FARGATE"
}
type = "MANAGED"
}
This is how to easily enable ContainerInsights on an ECS cluster using Terraform:
resource "aws_ecs_cluster" "foo" {
name = ""
setting {
name = "containerInsights"
value = "enabled"
}
}
Notes:
- I checked and it seems that it's not possible to pass an existing ECS cluster to the creation of the compute environment - Reference