Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terraform not saving state of ECS Cluster containerInsights setting

This is my template:

resource "aws_ecs_cluster" "doesntmatter" {
  name = var.doesntmatter_name

  capacity_providers = ["FARGATE", "FARGATE_SPOT"]
  setting {
    name  = "containerInsights"
    value = "enabled"
  }

  tags = var.tags
}

When I run it. It properly creates cluster and sets containerInsights to enabled. enter image description here

But when I run terrafrom again. It wants to change this property as if it wasn't set before. It doesn't matter how many times I run it. It still thinks it needs to change it every deployment.

enter image description here

Additionally, the terraform state show resName does show that this setting is saved in state file.

like image 563
Hooch Avatar asked Sep 02 '21 10:09

Hooch


1 Answers

It's a bug that is resolved with v3.57.0 of the Terraform AWS Provider (released yesterday).

Amazon ECS is making a change to the ECS Describe-Clusters API. Previously, the response to a successful ECS Describe-Clusters API request included the cluster settings by default. This behavior was incorrect since, as documented here (https://docs.aws.amazon.com/cli/latest/reference/ecs/describe-clusters.html), cluster settings is an optional field that s hould only be included when explicitly requested by the customer. With the change, ECS will no longer surface the cluster settings field in response to the Describe-Clusters API by default. Customers can continue to use the --include SETTINGS flag with the Describe-Clusters API to receive the cluster settings.

Tracking bug: https://github.com/hashicorp/terraform-provider-aws/issues/20684

like image 129
Topher Avatar answered Oct 23 '22 10:10

Topher