Terraform-provider-newrelic: Unable to import newrelic_alert_channel resource of type webhook

Created on 4 Feb 2020  路  2Comments  路  Source: newrelic/terraform-provider-newrelic

Terraform Version

Terraform v0.11.11

  • provider.newrelic v1.12.2

Affected Resource(s)

  • newrelic_alert_channel

Terraform Configuration Files

resource "newrelic_alert_channel" "pagerduty_v2_alerts" {
  name = "pagerduty-v2-alerts"
  type = "webhook"

  config {
    base_url = "https://events.pagerduty.com/v2/enqueue"
    # TODO - add headers and payload
  }
}

Debug Output

$ terraform import newrelic_alert_channel.pagerduty_v2_alerts 2828189
Acquiring state lock. This may take a few moments...
newrelic_alert_channel.pagerduty_v2_alerts: Importing from ID "2828189"...
newrelic_alert_channel.pagerduty_v2_alerts: Import prepared!
  Prepared newrelic_alert_channel for import
newrelic_alert_channel.pagerduty_v2_alerts: Refreshing state... [id=2828189]

Error: config.0.payload.payload: '' expected type 'string', got unconvertible type 'map[string]interface {}'


Releasing state lock. This may take a few moments...

Expected Behavior

Resource should import without an error.

Actual Behavior

Failed with the error shown above.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform import newrelic_alert_channel.pagerduty_v2_alerts 2828189

Important Factoids

Here's what the resource looks like from the UI. Hopefully this is easy to reproduce.

image

Text of JSON payload:

{
  "payload": {
    "summary": "$CONDITION_NAME",
    "source": "$POLICY_NAME",
    "severity": "info",
    "custom_details": {
      "account_id": "$ACCOUNT_ID",
      "account_name": "$ACCOUNT_NAME",
      "closed_violations_count_critical": "$CLOSED_VIOLATIONS_COUNT_CRITICAL",
      "closed_violations_count_warning": "$CLOSED_VIOLATIONS_COUNT_WARNING",
      "condition_family_id": "$CONDITION_FAMILY_ID",
      "condition_id": "$CONDITION_ID",
      "condition_name": "$CONDITION_NAME",
      "current_state": "$EVENT_STATE",
      "details": "$EVENT_DETAILS",
      "duration": "$DURATION",
      "event_type": "$EVENT_TYPE",
      "incident_acknowledge_url": "$INCIDENT_ACKNOWLEDGE_URL",
      "incident_id": "$INCIDENT_ID",
      "incident_url": "$INCIDENT_URL",
      "open_violations_count_critical": "$OPEN_VIOLATIONS_COUNT_CRITICAL",
      "open_violations_count_warning": "$OPEN_VIOLATIONS_COUNT_WARNING",
      "owner": "$EVENT_OWNER",
      "policy_name": "$POLICY_NAME",
      "policy_url": "$POLICY_URL",
      "runbook_url": "$RUNBOOK_URL",
      "severity": "$SEVERITY",
      "targets": "$TARGETS",
      "timestamp": "$TIMESTAMP",
      "violation_callback_url": "$VIOLATION_CALLBACK_URL",
      "violation_chart_url": "$VIOLATION_CHART_URL"
    }
  },
  "routing_key": "REDACTED,
  "links": [{
    "href": "$INCIDENT_URL",
    "text": "NewRelic Incident URL"
  }],
  "event_action": "trigger",
  "client": "NewRelic",
  "client_url": "https://one.newrelic.com"
}

References

I know this code has been changed quite a bit in recent versions of the provider.

bug

All 2 comments

@pickgr we have a fix being released for this shortly.

@ctrombley verified that this is resolved with version 1.13.1 . Thanks for the quick turn-around!

Was this page helpful?
0 / 5 - 0 ratings