Coder Social home page Coder Social logo

Comments (5)

tpederson-indeed avatar tpederson-indeed commented on August 16, 2024

I've been tearing apart my code bit by bit, and I've isolated it to this part.

filter_chains.tf:

resource "ns1_datafeed" "filter_chain" {
  for_each = var.monitor_to_ip_and_record

  name      = each.key
  source_id = ns1_datasource.datasource[var.record_to_pagerduty_service[each.value.record]].id

  config = {
    jobid = ns1_monitoringjob.filter_chain[each.key].id
  }
}

resource "ns1_monitoringjob" "filter_chain" {
  for_each = var.monitor_to_ip_and_record

  active          = true
  regions         = ["dal", "sin", "sjc", "lga", "ams"]
  job_type        = "tcp"
  frequency       = 60
  rapid_recheck   = true
  policy          = "quorum"
  notify_failback = true

  name = each.key

  # notify_list     = ns1_notifylist.notifylist[var.record_to_pagerduty_service[each.value.record]].id
  # notify_regional = false

  # rules {
  #   comparison = "contains"
  #   key        = "output"
  #   value      = "OK"
  # }
  # rules {
  #   comparison = "<"
  #   key        = "connect"
  #   value      = "5000"
  # }
  config = {
    ssl  = "1"
    # send = "GET /info/healthcheck?source=ns1/ HTTP/1.1\r\nHost: ${var.record_to_host_header[each.value.record]}\r\n\r\n"
    host = each.value.ip
    port = "443"
  }
}

variables.tf.json:

{
  "variable": {
    "monitor_to_ip_and_record": {
      "default": {
        "Americas Jobsearch pdxprod1-offload1001": {
          "ip": "35.165.48.217",
          "record": "americas"
        },
        "Americas Jobsearch pdxprod1-offload1002": {
          "ip": "35.162.238.247",
          "record": "americas"
        }
      }
    }
  }
}

I've been commenting out parts, but it seems to be throwing the divide by zero error from the main foreach:

resource "ns1_monitoringjob" "filter_chain" {
  for_each = var.monitor_to_ip_and_record

from terraform-provider-ns1.

tpederson-indeed avatar tpederson-indeed commented on August 16, 2024

I had it wrong above. This works:

{
  "variable": {
    "monitor_to_ip_and_record": {
      "default": {
        "Americas Jobsearch pdxprod1-offload1001": {
          "ip": "35.165.48.217",
          "record": "americas"
        },
        "Americas Jobsearch pdxprod1-offload1002": {
          "ip": "35.162.238.247",
          "record": "americas"
        },
        "Americas Jobsearch pdxprod1-offload1003": {
          "ip": "54.203.219.73",
          "record": "americas"
        }
      }
    }
  }
}

This throws the error, however:

{
  "variable": {
        "Americas Jobsearch pdxprod1-offload1001": {
          "ip": "35.165.48.217",
          "record": "americas"
        },
        "Americas Jobsearch pdxprod1-offload1002": {
          "ip": "35.162.238.247",
          "record": "americas"
        },
        "Americas Jobsearch pdxprod1-offload1003": {
          "ip": "54.203.219.73",
          "record": "americas"
        },
        "Americas Jobsearch cmh-offload1001": {
          "ip": "18.216.114.70",
          "record": "americas"
        },
        "Americas Jobsearch cmh-offload1002": {
          "ip": "3.17.53.43",
          "record": "americas"
        },
        "Americas Jobsearch cmh-offload1003": {
          "ip": "18.218.22.89",
          "record": "americas"
        }
      }
    }
  }
}

from terraform-provider-ns1.

eravin-ns1 avatar eravin-ns1 commented on August 16, 2024

Sorry for the delayed response. We haven't tracked this problem all the way to the bottom yet, but we've released v1.13.2-pre1 which should prevent the crash. As it's a prerelease, you'll need to specify the version explicitly in your resource file:

      source = "ns1-terraform/ns1"
      version = "1.13.2-pre1"

If this doesn't solve the problem, please generate logs with TF_LOG=debug NS1_DEBUG=1 terraform apply ... and submit them via an NS1 support ticket.

from terraform-provider-ns1.

eravin-ns1 avatar eravin-ns1 commented on August 16, 2024

Release 1.13.2-pre2 should fix this by adding retries for 502/503 errors (which exposed the divide-by-zero bug fixed in 1.13.2-pre1).

from terraform-provider-ns1.

eravin-ns1 avatar eravin-ns1 commented on August 16, 2024

Closing, this fixed in 1.13.2-pre2 and above.

from terraform-provider-ns1.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.