I recently returned to a terraform project after a couple of months. Upon cutting a new release, I received the error:
ECS Task Definition container_definitions is invalid: decoding JSON: json: cannot unmarshal Go value of type array into...
I traced the error back to a Lambda Function where the environment variables were being loaded from a JSON dictionary stored in AWS Secrets Manger. The error indicates that Terraform cannot convert one of the input key-value pairs into a string value. There is no indication of which key-value pair is causing the issue.
Solution: Adding quotes to the value in the terraform code fixed the issue. There must have been a type-checking update that enforced the string data type in the environment variable values. I added quotes around local.secrets
in the configuration below to fix the issue.
ecs-env-list = [for k in keys(local.secrets) : { "name" : k, "value" : "local.secrets[k]" }]