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

ns1_notifylist notifications objects are not supposed to be ordered and deterministic #301

Closed
Slabimic opened this issue Oct 5, 2023 · 2 comments
Assignees

Comments

@Slabimic
Copy link

Slabimic commented Oct 5, 2023

Hi, I'm seeing the inconsistent ordering issue when using ns1_notifylist resource with multiple notifications objects.

Terraform Version

# terraform --version
Terraform v1.5.3
on linux_amd64

Terragrunt version

# terragrunt --version
terragrunt version v0.48.1

Affected Resource(s)

  • ns1_notifylist

Terraform Configuration Files

resource "ns1_notifylist" "prod" {
  name  = "team PROD [${var.clusterid}]"
  notifications {
    type = "email"
    config = {
      email = "abc@gmail.com"
    }
  }
  notifications {
    type = "email"
    config = {
      email = "def@gmail.com"
    }
  }
  notifications {
    type = "slack"
    config = {
      url      = var.slack.webhooks["alerts"].url
      channel  = "#alerts"
      username = "[${var.clusterid}] PROD NS1 monitor"
    }
  }
}

Expected Behavior

Stable clean terraform plan/apply once deployed within the same configuration (No changes).

Actual Behavior

It deploys and configures resources in NS1 properly, but it tries to reshuffle values with another run. The issue is that NS1 probably does not care about order. Hence it sets values in some internal order, and changing the order via NS1 API does nothing with NS1 values. I see the same diff even after several passed successful terraform apply.

Initial run (first apply)

    - '  # ns1_notifylist.prod[0] will be created'
    - '  + resource "ns1_notifylist" "prod" {'
    - '      + id   = (known after apply)'
    - '      + name = "team PROD [171]"'
    - ''
    - '      + notifications {'
    - '          + config = {'
    - '              + "email" = "abc@gmail.com"'
    - '            }'
    - '          + type   = "email"'
    - '        }'
    - '      + notifications {'
    - '          + config = {'
    - '              + "email" = "def@gmail.com"'
    - '            }'
    - '          + type   = "email"'
    - '        }'
    - '      + notifications {'
    - '          + config = {'
    - '              + "channel"  = "#alerts"'
    - '              + "url"      = "https://hooks.slack.com/services/somehookid"'
    - '              + "username" = "[171] PROD NS1 monitor"'
    - '            }'
    - '          + type   = "slack"'
    - '        }'
    - '      + notifications {'
    - '          + config = {'
    - '              + "sourceid" = "somedatafeedssourceid"'
    - '            }'
    - '          + type   = "datafeed"'
    - '        }'
    - '    }'

Other runs of plan or apply

  # ns1_notifylist.prod[0] will be updated in-place
  ~ resource "ns1_notifylist" "prod" {
        id   = "ns1_notifylist_id"
        name = "team PROD [171]"

      ~ notifications {
          ~ config = {
              - "channel"  = "#alerts" -> null
              + "email"    = "def@gmail.com"
              - "url"      = "https://hooks.slack.com/services/somehookid" -> null
              - "username" = "[171] PROD NS1 monitor" -> null
            }
          ~ type   = "slack" -> "email"
        }
      ~ notifications {
          ~ config = {
              + "channel"  = "#alerts"
              - "email"    = "def@gmail.com" -> null
              + "url"      = "https://hooks.slack.com/services/somehookid"
              + "username" = "[171] PROD NS1 monitor"
            }
          ~ type   = "email" -> "slack"
        }

        # (2 unchanged blocks hidden)
    }

It shows the same output/diff until the affected resource is deleted and recreated again.

Steps to Reproduce

  1. Define several resources with the configuration from the example.
  2. terraform apply
  3. terraform plan or terraform apply again anytime later

Important Factoids

We use the terragrunt to maintain resources with different values using variables (eg. ${var.clusterid} variable).
It is important to have more resources created so different ordering in the NS1 setup might occur. I was not able to reproduce it easily with single resource deployment, but having 6 of them was enough (eg. several different clusters).

References

Might be similar to:

@fformica
Copy link
Contributor

Hi, this should be fixed by #301
I'll assign this ticket to me and update with the release version.

@fformica fformica self-assigned this Apr 22, 2024
@fformica
Copy link
Contributor

fformica commented Jun 5, 2024

Hi, this was released in 2.2.2

@fformica fformica closed this as completed Jun 5, 2024
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

No branches or pull requests

2 participants