Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform producing unnecessarily noisy diffs due to omitted lists #165

Open
mightyguava opened this issue Jun 9, 2023 · 0 comments
Open
Labels
bug 🐛 An issue with the system

Comments

@mightyguava
Copy link

mightyguava commented Jun 9, 2023

Describe the Bug

Moving from module version 0.58.2 to 0.60.0, Terraform is creating unnecessarily noisy diffs for empty list values. It doesn't impact whether a change is detected on the task definition or not, just the size of the diff, presumably due to the way Terraform is treating [] and omitted the same.

Pasting part of the diff below

              ~ {
                  - mountPoints            = []
                    name                   = "log-router"
                  - portMappings           = []
                  - volumesFrom            = []
                    # (8 unchanged attributes hidden)
                },
              ~ {
                  ~ environment            = [
                        # (2 unchanged elements hidden)
                        {
                            name  = "DD_LOGS_ENABLED"
                            value = "true"
                        },
                      ~ {
                            name  = "DD_VERSION"
                          ~ value = "fake-tag-for-template" -> "326d5e5572a9f7b4fd8c54fa243a84af094dac5b"
                        },
                        {
                            name  = "ECS_FARGATE"
                            value = "true"
                        },
                    ]
                  - mountPoints            = []
                    name                   = "datadog"
                  - volumesFrom            = []
                    # (7 unchanged attributes hidden)
                },

Expected Behavior

Here's a diff using 0.58.2. Notice that mountPoints, portMappings, and volumesFrom don't show that they are being removed.

                {
                    cpu                    = 0
                    environment            = []
                    essential              = true
                    firelensConfiguration  = {
                        options = {
                            enable-ecs-log-metadata = "true"
                        }
                        type    = "fluentbit"
                    }
                    image                  = "public.ecr.aws/aws-observability/aws-for-fluent-bit:latest"
                    logConfiguration       = {
                        logDriver = "awslogs"
                        options   = {
                            awslogs-group         = "main/fromagerie-job-migrate-from-unified-keysets"
                            awslogs-region        = "us-west-2"
                            awslogs-stream-prefix = "fluentbit"
                        }
                    }
                    mountPoints            = []
                    name                   = "log-router"
                    portMappings           = []
                    readonlyRootFilesystem = false
                    user                   = "0"
                    volumesFrom            = []
                },
              ~ {
                  ~ environment            = [
                        # (2 unchanged elements hidden)
                        {
                            name  = "DD_LOGS_ENABLED"
                            value = "true"
                        },
                      ~ {
                            name  = "DD_VERSION"
                          ~ value = "fake-tag-for-template" -> "326d5e5572a9f7b4fd8c54fa243a84af094dac5b"
                        },
                        {
                            name  = "ECS_FARGATE"
                            value = "true"
                        },
                    ]
                    name                   = "datadog"
                    # (9 unchanged attributes hidden)
                },
            ] # forces replacement

Steps to Reproduce

Run plan on any task definition with changes that would cause the task definition to be replaced, where mountPoints or portMappings, etc, is omitted from the container definition or an [] is provided.

Screenshots

No response

Environment

Terraform v1.4.6
on darwin_arm64

  • provider registry.terraform.io/hashicorp/aws v5.1.0
  • provider registry.terraform.io/hashicorp/local v2.4.0
  • provider registry.terraform.io/hashicorp/null v3.2.1
  • provider registry.terraform.io/hashicorp/time v0.9.1

Additional Context

I think the problem is that the ECS task definition API is returning [] for list fields that are unset. Maybe these fields should be set to [] when not provided in the container definition as well? @go

@mightyguava mightyguava added the bug 🐛 An issue with the system label Jun 9, 2023
@mightyguava mightyguava changed the title Terraform producing unnecessarily large diffs due to omitted lists Terraform producing unnecessarily noisy diffs due to omitted lists Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

No branches or pull requests

1 participant