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

Cannot update workflow

Open KolesnikRV opened this issue 2 years ago • 2 comments

Terraform Version

Terraform v1.2.8
on linux_amd64
+ provider registry.terraform.io/newrelic/newrelic v3.1.0

Affected Resource(s)

  • newrelic_workflow

Terraform Configuration

main.tf

locals {
    monitors = {"HAMSTER" : "", "HAMSTER2": "", "HAMSTER3": ""}
}


resource "newrelic_synthetics_monitor" "add_monitors" {
    account_id = var.account_id
    for_each          = local.monitors
    name              = each.key
    uri               = "https://ttest.com"
    type              = "SIMPLE"
    period            = "EVERY_MINUTE"
    status            = "ENABLED"
    locations_public  = ["EU_CENTRAL_1", "EU_WEST_3", "EU_NORTH_1"]
    verify_ssl        = "false"
}

resource "newrelic_alert_policy" "add_policies" {
    name                = "TEST"
    incident_preference = "PER_CONDITION"
}

resource "newrelic_synthetics_alert_condition" "add_conditions" {
    for_each    = local.monitors
    policy_id   = newrelic_alert_policy.add_policies.id
    name        = newrelic_synthetics_monitor.add_monitors[each.key].name
    monitor_id  = newrelic_synthetics_monitor.add_monitors[each.key].id
    runbook_url = newrelic_synthetics_monitor.add_monitors[each.key].uri
}

resource "newrelic_notification_destination" "add_webhook_destination" {
    account_id = var.account_id
    name       = "DESTINATION_TEST"
    type       = "WEBHOOK"

    property {
        key   = "url"
        value = "http://testt.com"
    }
    auth_basic {
        user     = "user"
        password = "1234"
    }
}

resource "newrelic_notification_channel" "add_webhook_channel" {
    account_id     = var.account_id
    name           = "CHANNEL_TEST"
    type           = "WEBHOOK"
    destination_id = newrelic_notification_destination.add_webhook_destination.id
    product        = "IINT"

    property {
        key   = "payload"
        value = "Issue title: {{issueTitle}},\n Issue url: {{ issuePageUrl }},\n priority: {{ priority }},\n workflowName: {{ workflowName }}"
        label = "Payload Template"
    }
}


resource "newrelic_workflow" "add_webhook_workflow" {
    account_id            = var.account_id
    name                  = "workflow"
    destinations_enabled  = true
    enrichments_enabled   = false
    workflow_enabled      = true
    muting_rules_handling = "DONT_NOTIFY_FULLY_MUTED_ISSUES"

    issues_filter {
        name = "policy filter"
        type = "FILTER"

        predicates {
            attribute = "accumulations.conditionName"
            operator  = "CONTAINS"
            values    = keys(local.monitors)
        }
    }

    destination_configuration {
        channel_id = newrelic_notification_channel.add_webhook_channel.id
    }
}

Actual Behavior

Create/delete workflow working well Trying to change predicates values for monitor: Just add another monitor to condition in workflow

#terraform apply

╷
│ Error: maximum retries reached: An error occurred resolving this field
│ 
│   with newrelic_workflow.add_webhook_workflow,
│   on main.tf line 62, in resource "newrelic_workflow" "add_webhook_workflow":
│   62: resource "newrelic_workflow" "add_webhook_workflow" {
│ 
╵

Expected Behavior

update workflow

Steps to Reproduce

  1. terraform apply
  2. add another monitor to local.monitors
  3. terraform apply

KolesnikRV avatar Sep 05 '22 13:09 KolesnikRV

I am having the same issue as above. When I turn on debug log an I can see the below logs:

---[ REQUEST ]---------------------------------------
POST /graphql HTTP/1.1

Host: api.newrelic.com

User-Agent: HashiCorp Terraform/1.0.11 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-newrelic/3.1.0
...
{
 "query": "mutation(\n\t$accountId: Int!,\n\t$updateWorkflowData: AiWorkflowsUpdateWorkflowInput!,\n) { aiWorkflowsUpdateWorkflow(\n\taccountId: $accountId, ....
 "variables": {
...
...
{
 "data": null,
 "errors": [
  {
   "extensions": {
    "errorClass": "SERVER_ERROR"
   },
   "locations": [
    {
     "column": 5,
     "line": 4
    }
   ],
   "message": "An error occurred resolving this field",
   "path": [
    "aiWorkflowsUpdateWorkflow"
   ]
  }
 ]
}

Hopefully that's extra info that helps with debugging. And this is a showstopper for us at the moment.

kaiqi-yang avatar Sep 06 '22 04:09 kaiqi-yang

Seeing this issue myself. Same scenario, attempting to modify issue filter predicates, along with the same error. Definitely a roadblock for migrating to workflows.

usfdmiller avatar Sep 06 '22 16:09 usfdmiller

This issue has been fixed as a byproduct of other various fixes of both the provider and our services.

To be on the safe side, I would recommend to update to the latest version of our TF provider (v3.5.1 at the time of writing this) because this is the version I used to confirm that this problem can no longer be reproduced.

IliaShurygin avatar Oct 20 '22 10:10 IliaShurygin