ns1-terraform / terraform-provider-ns1

Terraform NS1 provider
https://www.terraform.io/docs/providers/ns1/
Mozilla Public License 2.0
31 stars 63 forks source link

Inconsistent Filter Chain State #291

Closed dolvany closed 1 year ago

dolvany commented 1 year ago

% tf142 -v Terraform v1.4.2 on darwin_amd64

  1. Create a cname with filter chain via tf.
  2. Remove filter chain from the cname via tf. TF indicates that the change succeeded, but the nsone console still shows the filter chain on the record.
  3. Remove filter chain via the nsone console.
  4. Following a refresh, the filter chain still appears in the tf state, even though the ns1 api and console shows no filter chain on the record.

The result is the filter chain state never becoming consistent and tf attempting to replay the filter chain removal on every subsequent plan. It seems like there is something amiss with the refresh functionality of the ns1 provider, as if the provider is incorporating part of the current state in the refresh operation, instead of generating all new state on refresh.

jmtx1020 commented 1 year ago

Any chance you found a solution? @dolvany

I am also experiencing the above issue but with version 2.0.5 of the plugin and terraform version 1.4.6, I thought it'd be helpful for me to comment and provide some sample code:

resource "ns1_record" "test1" {
  zone   = var.zone
  domain = "test1.${var.zone}"
  type   = "A"
  ttl    = 3600
  answers {
    answer = "122.251.63.104"
    meta = {
      "latitude"  = "23"
      "longitude" = "-107"
    }
    region = "REGION1"
  }
  answers {
    answer = "123.231.63.103"
    meta = {
      "latitude"  = "55"
      "longitude" = "-107"
    }
    region = "REGION2"
  }

  # filters {
  #   config   = {}
  #   disabled = false
  #   filter   = "geotarget_latlong"
  # }
  # filters {
  #   config   = {}
  #   disabled = false
  #   filter   = "select_first_region"
  # }
  # filters {
  #   config = {
  #     "sticky_by_network" = "0"
  #   }
  #   disabled = false
  #   filter   = "sticky"
  # }
  # filters {
  #   config = {
  #     "N" = "1"
  #   }
  #   disabled = false
  #   filter   = "select_first_n"
  # }

  regions {
    meta = {}
    name = "REGION1"
  }
  regions {
    meta = {}
    name = "REGION2"
  }
}

Running a plan will show that it needs to remove the filter chain, applying will succeed. Rerun plan and it will show that it still needs to delete.

You can add as many filters as you like, however deleting them never works. You can see the filters are still there in the ns1 webstie.

pburrows-ns1 commented 1 year ago

@dolvany / @jmtx1020 Please try provider version 2.0.8