terraform-provider-checkly icon indicating copy to clipboard operation
terraform-provider-checkly copied to clipboard

bug: dettach snippets from check and check groups when properties get removed

Open ianaya89 opened this issue 3 years ago • 3 comments

ianaya89 avatar May 20 '21 00:05 ianaya89

I think I'm running into the same issue.

I have two groups defined like so:

me@mine:~/src/monitoring/checkly$ cat monitored_stacks.yml
- name: production
  region: us-west-2
[...]

- name: australia
  region: ap-southeast-2
[...]

checkly.tf:

locals {
  stacks                 = yamldecode(file("monitored_stacks.yml"))
  setup_script_get_token = <<-EOT
    const axios = require("axios");
    const url = require("url");

    const baseUrl = new url.URL(request.url);
[...]
}

resource "checkly_check_group" "all_groups" {
  # https://selleo.com/til/posts/cnfrqv1ipl-foreach-over-tuples-in-terraform
  for_each                  = { for stack in local.stacks : stack.name => stack }
  name                      = each.key
  local_setup_script        = local.setup_script_get_token
[...]
}

I'd like to move the setup script from the group to the individual checks (we added some checks to the group that don't need the setup script which gets a JWT).

So my goal is to remove the setup script from the group. I've tried many things, including:

resource "checkly_check_group" "all_groups" {
[...]
  local_setup_script        = ""
resource "checkly_check_group" "all_groups" {
[...]
  local_setup_script        = null
resource "checkly_check_group" "all_groups" {
[...]
  setup_snippet_id          = 0
  local_setup_script        = ""

But none of those remove the local setup script from the group.

Not sure if this is related, but when I have local_setup_script = null and run terraform with TF_LOG=trace, I see this:

checkly_1   | 2021/06/23 16:02:09 [DEBUG] checkly_check_group.all_groups["production"]: applying the planned Update change
checkly_1   | 2021/06/23 16:02:09 [TRACE] GRPCProvider: ApplyResourceChange
checkly_1   | 2021/06/23 16:02:10 [WARN] Provider "registry.terraform.io/checkly/checkly" produced an unexpected new value for checkly_check_group.all_groups["australia"], but we are tolerating it because it is using the legacy plugin SDK.
checkly_1   |     The following problems may be the cause of any confusing errors from downstream operations:
checkly_1   |       - .local_setup_script: was null, but now cty.StringVal("const axios = require(\"axios\");\nconst url = require(\"url\");\n\nconst baseUrl = new url.URL(request.url);\n [...] 
")

What is the correct way to disable a setup script in a group?

ryanchapman avatar Jun 23 '21 16:06 ryanchapman

@ryanchapman thanks for reporting. @ianaya89 can you have a look at this one?

tnolet avatar Jun 28 '21 07:06 tnolet

@ryanchapman sorry for the late response. Will take a look into this and get back to you. Is probably related to the issue I reported but want to make some tests before and try to find a workaround.

ianaya89 avatar Jun 29 '21 16:06 ianaya89