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

Excluded regions field changes order frequently #1647

Closed
enicholson125 opened this issue Nov 30, 2022 · 1 comment · Fixed by #1656
Closed

Excluded regions field changes order frequently #1647

enicholson125 opened this issue Nov 30, 2022 · 1 comment · Fixed by #1656

Comments

@enicholson125
Copy link

enicholson125 commented Nov 30, 2022

The excluded regions field shows a diff to change the order of the regions, even though the contents of the list hasn't changed. It would be good if the excluded regions field did not consider a change in order to be a change to the resource.

Terraform Version

1.3.5

Affected Resource(s)

  • datadog_integration_aws

Terraform Configuration Files

data "aws_region" "current" {}
data "aws_regions" "current" {
  all_regions = true
}

# This code is using the default value of this variable
variable "included_regions" {
  type        = list(string)
  default     = []
}

locals {
  aws_regions_all        = data.aws_regions.current.names
  aws_regions_target   = length(var.included_regions) > 0 ? var.included_regions : [data.aws_region.current.name]
}

resource "datadog_integration_aws" "aws_integration" {
  account_id = local.my_aws_account_id
  role_name  = var.datadog_role_name
  host_tags  = var.host_tags
  # only include specific regions (the Datadog provider only supports excluded regions)  
  excluded_regions                 = setsubtract(local.aws_regions_all, local.aws_regions_target)
  account_specific_namespace_rules = var.account_specific_namespace_rules
}

Expected Behavior

When the excluded regions list does not change, there should be no change in the datadog integration.

Actual Behavior

Sometimes (but not always), we see a flaky diff in the terraform plan to change the order of the regions, e.g.

Terraform will perform the following actions:

  # module.infrastructure.module.kaluza_datadog_integration[0].datadog_integration_aws.aws_integration will be updated in-place
  ~ resource "datadog_integration_aws" "aws_integration" {
      ~ excluded_regions                 = [
          - "us-east-1",
          - "us-east-2",
          - "us-west-1",
          - "us-west-2",
          - "eu-west-1",
          - "eu-central-1",
          - "eu-south-1",
          + "af-south-1",
            "ap-east-1",
          - "ap-southeast-1",
          - "ap-southeast-3",
            "ap-northeast-1",
            # (1 unchanged element hidden)
            "ap-northeast-3",
          - "me-south-1",
          - "me-central-1",
          - "af-south-1",
          - "sa-east-1",
            "ap-south-1",
          + "ap-south-2",
          + "ap-southeast-1",
          + "ap-southeast-3",
            "ca-central-1",
          + "eu-central-1",
          + "eu-central-2",
          + "eu-north-1",
          + "eu-south-1",
          + "eu-south-2",
          + "eu-west-1",
            "eu-west-2",
            "eu-west-3",
          - "eu-north-1",
          + "me-central-1",
          + "me-south-1",
          + "sa-east-1",
          + "us-east-1",
          + "us-east-2",
          + "us-west-1",
          + "us-west-2",
        ]
        id                               = "012345678912:DatadogAWSIntegrationRole"
        # (9 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Steps to Reproduce

  1. terraform plan

This step may be required multiple times, as we do not see this issue every time.

@nkzou
Copy link
Contributor

nkzou commented Dec 2, 2022

Unfortunately, Diffs of List types are not well supported with terraform-plugin-sdk. See hashicorp/terraform-plugin-sdk#477, DiffSuppressFunc doesn't support lists. We'll see what we can do about this, possibly migrate to a set or preemptively sorting the list. Hopefully we'll have an update and/or PR up soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants