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

Changing recipient details for Slack type recipient in honeycombio_trigger causes 422 failure #303

Closed
watsonm-drivevariant opened this issue Apr 24, 2023 · 2 comments · Fixed by #311
Labels
Milestone

Comments

@watsonm-drivevariant
Copy link

Versions
0.13.0 & 0.14.0

Steps to reproduce

  1. Create a simple terraform alert

main.tf:

data "honeycombio_query_specification" "query_specification" {
    calculation {
        op = "MAX"
        column = "metrics.cpu.usage"
    }

    filter { 
        column = "label.app"
        op = "="
        value = "jazz-backend-api"
    }
    time_range = 300
}

resource "honeycombio_query" "trigger_query" {
    dataset = "kubernetes-metrics"
    query_json = data.honeycombio_query_specification.query_specification.json
}

resource "honeycombio_trigger" "trigger" {
    name = "honeycomb-bug"
    description = "Created to reproduce observed honeycomb bug"
    query_id = honeycombio_query.trigger_query.id
    dataset = "kubernetes-metrics"
    frequency = 300
    alert_type = "on_change"
    threshold {
        op = ">"
        value = 0.9
    }
    recipient {
      type = "slack"
      target = "#my-alerting-channel"
    } 
}

settings.tf:

terraform { 
    required_providers { 
        honeycombio = {
            source = "honeycombio/honeycombio"
            version = "~> 0.14.0"
        }
    }
    required_version = "~> 1.1.7"
}

provider "honeycombio" {
}

Run terraform init and terraform apply to create alert. Answer prompts for api key, etc.

  1. Modify the target in the recipient block
 ...
  recipient {
    type = "slack"
    target = "#my-alerting-channel-2"
  }
  1. Once again, run terraform apply to make changes to the trigger.

The apply will create a plan

Terraform will perform the following actions:

  # honeycombio_trigger.trigger will be updated in-place
  ~ resource "honeycombio_trigger" "trigger" {
        id          = "pweHeSfZh9q"
        name        = "honeycomb-bug"
        # (6 unchanged attributes hidden)

      ~ recipient {
            id     = "m7wahgjr9SC"
          ~ target = "#my-alerting-channel" -> "#my-alerting-channel-2"
            # (1 unchanged attribute hidden)
        }

        # (1 unchanged block hidden)
    }

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

but fail when attempting to apply

╷
│ Error: 422 Unprocessable Entity: unknown recipient - check recipient id 'm7wahgjr9SC' values.
│ 
│   with honeycombio_trigger.trigger,
│   on main.tf line 20, in resource "honeycombio_trigger" "trigger":
│   20: resource "honeycombio_trigger" "trigger" {
│ 
╵

Additional context
Terraform version 1.1.7

I would expect to be able to use the same basic structure to both create triggers with slack recipients, and update the recipient later to go to a new channel if necessary. The issue above poses problems when attempting to use input variables to fill trigger details while creating multiple triggers. Especially when it is not known ahead of time which recipients already exist and which do not.

@jharley jharley added the bug label Apr 25, 2023
@jharley
Copy link
Collaborator

jharley commented Apr 25, 2023

Thank you for taking the time to report this.

This is another manifestation of the buggy state of these recipient blocks.

Related to #200, #263, and #267

@jharley jharley added this to the 1.0.0 milestone Apr 25, 2023
jharley added a commit that referenced this issue May 31, 2023
This completes the move of the `honeycombio_trigger` resource to the
Terraform Plugin Framework (started in #306).

In order to support versions of Terraform core older than 1.4.0 (which,
is rather "fresh") there is a bit of logic to handle `Null` or `Unknown`
values of these awkwardly-shaped notification recipients.

This also 'bumps' the version of Terraform core used in CI to 1.0.11
(from the old 0.14.x series).

- Closes #303, #267, #200
@jharley
Copy link
Collaborator

jharley commented Jun 2, 2023

Fix released in v0.15.0

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

Successfully merging a pull request may close this issue.

2 participants