cn-terraform / terraform-aws-ecs-fargate

AWS ECS Fargate Terraform Module
https://registry.terraform.io/modules/cn-terraform/ecs-fargate
Apache License 2.0
87 stars 57 forks source link

Env variables trigger task definition to recreate on every apply #9

Closed advissor closed 4 years ago

advissor commented 4 years ago

Hi ,

I have two env vars that I pass to task definition. So, every time I plan or apply it mentiones force replacement and highlights that it gonna recreate the variables (in plan show different order) . There are no changes in vars I tried to declare values with = , : and etc to test if this matters - no difference

https://github.com/hashicorp/terraform/issues/23780

Also, in plan output some of values to be set to null or to be changed

I've been checking issues of others on the web and there seem to be some similar cases due to :

Have you seen such behavior?

  # module.ecs-fargate.module.ecs-fargate-task-definition.aws_ecs_task_definition.td must be replaced
-/+ resource "aws_ecs_task_definition" "td" {
      ~ arn                      = "arn:aws:ecs:xx-xxx-1:xxxxxxxxxxxxx:task-definition/qa2-td:68" -> (known after apply)
      ~ container_definitions    = jsonencode(
          ~ [ # forces replacement
              ~ {
                  + command                = null
                    cpu                    = xxxx
                  + dependsOn              = null
                  + dnsServers             = null
                  + dockerLabels           = null
                  + entryPoint             = null
                  ~ environment            = [
                      - {
                          - name  = "CXX_XXX"
                          - value = "[[XX:xxxx-X/xxxx]]xxxxx/xxxxx.png"
                        },
                        {
                            name  = "CYY_YYY"
                            value = "[[YY:YYYY-Y/YYY-YYYY]]YYYYY/xxxxx.txt""
                        },
                      + {
                          + name  = "CYY_XXX"
                          + value = "[[XX:xxxx-x/xxxx]]xxxxx/xxxxx.png"
                        },
                    ]
            ~ protocol      = "tcp" -> "HTTP"
             ~ mountPoints            = [] -> null
                  + firelensConfiguration  = null
                  + healthCheck            = null
                  + links                  = null
               ~ volumesFrom            = [] -> null
                     - tags                     = {} -> null
jnonino commented 4 years ago

Tested the latest version of the module (2.0.12) in another module I have (Sonar) and did not have this problem.

module "sonar" {
  source  = "cn-terraform/sonarqube/aws"
  version = "2.0.7"

  name_preffix        = var.name_preffix
  profile             = var.profile
  region              = var.region
  vpc_id              = module.networking.vpc_id
  availability_zones  = module.networking.availability_zones
  public_subnets_ids  = module.networking.public_subnets_ids
  private_subnets_ids = module.networking.private_subnets_ids
}