Giter Site home page Giter Site logo

newrelic / terraform-provider-newrelic Goto Github PK

View Code? Open in Web Editor NEW
199.0 30.0 241.0 64.56 MB

Terraform provider for New Relic

Home Page: https://registry.terraform.io/providers/newrelic/newrelic/latest/docs

License: Mozilla Public License 2.0

Makefile 0.77% Go 98.60% Shell 0.38% HTML 0.16% Dockerfile 0.01% HCL 0.01% JavaScript 0.08%
terraform terraform-provider newrelic developer-toolkit developer-tools hacktoberfest

terraform-provider-newrelic's Introduction

Community Plus header

New Relic Terraform Provider

New Relic offers tools that help you fix problems quickly, maintain complex systems, improve your code, and accelerate your digital transformation. With the New Relic Terraform provider you are able to automate the configuration of New Relic.

Requirements

New Relic and the Terraform team will support Terraform versions up to 2 years after the latest release. We advice to always upgrade to the latest version of Terraform and the New Relic Terraform provider.

Using the provider

To use the latest version of the provider in your Terraform environment, run terraform init and Terraform will automatically install the provider.

If you wish to pin your environment to a specific release of the provider, you can do so with a required_providers statement in your Terraform manifest. The terraform configuration block varies slightly depending on which Terraform version you're using. See below for more examples of configuring the provider version for the different versions of Terraform.

For Terraform version 1.x and above

terraform {
  required_version = "~> 1.0"
  required_providers {
    newrelic = {
      source  = "newrelic/newrelic"
    }
  }
}

If you're developing and building the provider locally, follow the instructions in our contribution guide.

For more information on using the provider and the associated resources, please see the provider documentation page.

Support

Should you need assistance with New Relic products, you are in good hands with several support channels.

Support Channels

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (version 1.18 is required). You'll also need to correctly setup a GOPATH, as well as adding $GOPATH/bin to your $PATH.

Please see our CONTRIBUTING guide for more information about developing and testing the New Relic Terraform provider.

Go Version Support

We'll aim to support the latest supported release of Go, along with the previous release. This doesn't mean that building with an older version of Go will not work, but we don't intend to support a Go version in this project that is not supported by the larger Go community. Please see the Go releases page for more details.

terraform-provider-newrelic's People

Contributors

acondrat avatar amaor-newrelic avatar asanuy avatar ctrombley avatar emetcalf9 avatar grubernaut avatar iliashurygin avatar jamesgoodhouse avatar jaymcgrath avatar kidk avatar lucasmessinar avatar lzaga-newrelic avatar mbazhlekova avatar nandu-pns avatar nilventosa avatar nr-developer-toolkit avatar nsspkrishna avatar nzur-newrelic avatar paultyng avatar pranav-new-relic avatar radeksimko avatar ravitejasurampudi avatar renovate-bot avatar renovate[bot] avatar sandeepkumar-kagitha avatar sanderblue avatar shiva-bandari avatar smithclay avatar sowmyajujjuri avatar zlesnr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-provider-newrelic's Issues

Can I put in api_key from a vault file without hardcoding it? If so, how?

I have tried:

Configure the New Relic provider

provider "newrelic" {
api_key = "${var.newrelic_api_key}"
}

variable "newrelic_api_key" {
default = "..."
}

"${data.terraform_remote_state.monitoring.newrelic_api_vault}" ---- default cannot have interpolation syntax

Could I do it using a token in the provider?

Unable to set custom headers for webhook alert channel

Terraform Version

Terraform v0.10.6

Affected Resource(s)

  • newrelic_alert_channel

Terraform Configuration Files

resource "newrelic_alert_channel" "api" {
  name = "API"
  type = "webhook"

  configuration = {
    base_url = "${var.url}"

    headers = {
      x-api-key = "${var.api_key}"
    }
  }
}

Expected Behavior

Create alert channel with custom header x-api-key.

Actual Behavior

1 error(s) occurred:

* newrelic_alert_channel.api: configuration (headers): '' expected type 'string', got unconvertible type '[]map[string]interface {}'

Steps to Reproduce

  1. terraform apply

Newrelic resource not utilizing HTTP_PROXY environment variables

This issue was originally opened by @pchug as hashicorp/terraform#15217. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.9.8

Affected Resource(s)

Terraform Configuration Files

Simple terraform configuration file that connects to newrelic API

provider "newrelic" {
  api_key = "${var.newrelic_api_key}"
}

# Create an alert policy
resource "newrelic_alert_policy" "policy1" {
  name = "Policy Test"
}

Debug Output

Terraform apply output

Panic Output

N/A

Expected Behavior

newrelic resource should be respecting the $HTTP_PROXY or $HTTPS_PROXY environment variables.

Actual Behavior

Terraform apply tries to connect to newrelic API endpoint directly on port 443, which isn't permitted from this machine.

Without this support for proxy, using terraform's newrelic resource is impossible for us. 😞

Steps to Reproduce

See linked gist for the details. The environment variables are set correctly and are functional. And then a simple terraform apply is being executed.

Important Factoids

Digging further into this, I see that newrelic provider uses https://github.com/paultyng/go-newrelic library, which uses https://github.com/go-resty/resty to make the connection to the newrelic API. resty's documentation says that they support and respect HTTP_PROXY environment variables. However, something along the chain doesn't seem to pass that environment variable through.

References

None.

newrelic_alert_channel with slack always recreate resources

version

$ terraform -version
Terraform v0.11.13
+ provider.newrelic v1.5.0
resource "newrelic_alert_channel" "slack" {
  name = "slack"
  type = "slack"

  configuration = {
    channel = "test"
    url     = "https://hooks.slack.com/services/xxxx/xxxxx"
  }
}

This always destroy/create on terraform apply repeatedly without any modifications.

-/+ newrelic_alert_channel.slack (new resource required)
      id:                    "2344397" => <computed> (forces new resource)
      configuration.%:       "1" => "2" (forces new resource)
      configuration.channel: <sensitive> => <sensitive> (attribute changed)
      configuration.url:     <sensitive> => <sensitive> (forces new resource)
      name:                  "slack" => "slack"
      type:                  "slack" => "slack"

newrelic_application data source: Chicken/Egg Problem retrieving application ID

Terraform Version

v0.11.8

Affected Resource(s)

  • newrelic_application data source
  • newrelic_alert_condition resource

Terraform Configuration Files

Consider the case where:

  • I'm configuring some infrastructure to be able to run an application (eg, an AWS ECS cluster+service)
  • I'm configuring an NewRelic alert condition, associated with that application

Let's say I'm running terraform for the first time, to configure both the application and the NewRelic alerts+conditions. I'll have some HCL like

# Configure the application
resource "aws_ecs_task_definition" "service" {
   // ...
  container_definitions = <<JSON
  {
    ...
    "environment": [{
      "name": "NEW_RELIC_APP_NAME",
      "value": "my-app"
    }]
  }
JSON
}

# Configure a New Relic alert condition
resource "newrelic_nrql_alert_condition" "some_condition" {
  // ...

  // Condition must reference Application by unique ID
  // Only way to get this ID is via a `newrelic_application` data source
  entities = ["${data.newrelic_application.my_app.id}"]
}

data "newrelic_application" "my_app" {
  name = "my-app"
}

The problem is that when I first run this terraform configuration, the application has not yet been registered in NewRelic, so the newrelic_application data source fails at terraform plan with:

Error: Error refreshing state: 1 error(s) occurred:

* data.newrelic_application.my_app: 1 error(s) occurred:

* data.newrelic_application.my_app: data.newrelic_application.my_app: The name 'my-app' does not match any New Relic applications.

I'm not sure how exactly you could work around this, but any ideas would be appreciated.

Debug Output

N/A

Panic Output

N/A

Expected Behavior

See Terraform Configuration Files above

Actual Behavior

See Terraform Configuration Files above

Steps to Reproduce

See Terraform Configuration Files above

Important Factoids

See Terraform Configuration Files above

References

Support for CRUD synthetics alerts and scripts

Hi! Maintaining our synthetics scripts and alerts via terraform has been a desire of ours for a while. We're looking to contribute in the coming weeks, but wanted to put this on the board and double-check whether this was already being planned or worked on.

Thanks for maintaining!

Internal Server Error - newrelic_alert_policy_channel linking not working

Terraform Version

0.11.11

Affected Resource(s)

  • terraform-provider-newrelic -> newrelic_alert_policy_channel

Terraform Configuration Files

Sample below - I have 6 app policies linked to same alert channel

resource "newrelic_alert_policy" "app_policy" {
  name = "app-policy"
}
resource "newrelic_alert_policy" "app2_policy" {
  name = "app2-policy"
}
resource "newrelic_alert_channel" "slack" {
  name = "Alerts"
  type = "slack"
  configuration = {
    url              = "${var.slack_alerts_channel_webhook_url}"
    channel = "alerts"
  }
}
resource "newrelic_alert_policy_channel" "alert_slack_app" {
  policy_id  = "${newrelic_alert_policy.app_policy.id}"
  channel_id = "${newrelic_alert_channel.slack.id}"
}
resource "newrelic_alert_policy_channel" "alert_slack_app2" {
  policy_id  = "${newrelic_alert_policy.app2_policy.id}"
  channel_id = "${newrelic_alert_channel.slack.id}"
}

Debug Output

https://gist.github.com/hackjoy/e5423875f2b4e2b5aeedb078b0df659a

Expected Behavior

  • No internal server errors should occur in output
  • Policies should be correctly linked to alert channel in New Relic Alerts UI

Actual Behavior

  • All resources (policies and alert channels) are created successfully however
    • Internal server errors shown in output
    • Some alert policies are linked to the desired channel but not all. The result varies on each run of terraform apply. Of the 6 newrelic_alert_policy_channel's I have, sometimes only 2, 3 or 4 of the policies are correctly linked together.

Steps to Reproduce

  1. Create 6 alert policies linked to a single alert channel and apply the changes with terraform apply

References

Potentially relevant issues discussed:

newrelic_infra_alert_condition not saving state leading to duplicate resources

Terraform Version

Terraform v0.11.13
provider.newrelic v1.5.0

Affected Resource(s)

newrelic_infra_alert_condition

This issue seems to affect multiple resources, but always newrelic_infra_alert_condition resources. I have a large set of ~300 new relic resources I'm applying. The first time I apply, the resources are all created as expected. However, another apply prompts me to create 6 new resources, which will duplicate existing resources. If I create them and then apply again, a different set of 6 resources will be created. This happens indefinitely, but always a set of 6 resources are prompted for creation (always creating duplicate resources).

Terraform Configuration Files

An example of a resource where this happens:

resource "newrelic_infra_alert_condition" "rabbitmq_server_offline" {
  policy_id = "${newrelic_alert_policy.application_infra_info.id}"
  name      = "RabbitMQ server offline"
  type      = "infra_host_not_reporting"
  where     = "(`hostname` LIKE '%${var.rabbitmq_server_hostname_pattern[local.env]}%')"

  critical {
    duration      = 5
    time_function = "all"
  }

  lifecycle {
    ignore_changes = ["critical.0.time_function"]
  }
}

Debug Output

I see the following output in the debug logs when doing a terraform apply targeting this resource:

2019/04/10 14:48:56 [DEBUG] Resource state not found for "newrelic_infra_alert_condition.rabbitmq_server_offline": newrelic_infra_alert_condition.rabbitmq_server_offline
2019-04-10T14:48:56.813-0700 [DEBUG] plugin.terraform-provider-newrelic_v1.5.0_x4: 2019/04/10 14:48:56 [DEBUG] Instance Diff is nil in Diff()
2019/04/10 14:48:56 [DEBUG] Resource state not found for "newrelic_infra_alert_condition.rabbitmq_server_offline": newrelic_infra_alert_condition.rabbitmq_server_offline
2019/04/10 14:48:56 [TRACE] Graph after step *terraform.AttachStateTransformer:
newrelic_infra_alert_condition.rabbitmq_server_offline - *terraform.NodePlannableResourceInstance
2019/04/10 14:48:56 [TRACE] Graph after step *terraform.TargetsTransformer:
newrelic_infra_alert_condition.rabbitmq_server_offline - *terraform.NodePlannableResourceInstance
2019/04/10 14:48:56 [DEBUG] ReferenceTransformer: "newrelic_infra_alert_condition.rabbitmq_server_offline" references: []
2019/04/10 14:48:56 [DEBUG] command: asking for input: "Do you want to perform these actions in workspace \"prod\"?"

If I choose to apply the change, it will be created, but will duplicate already existing resources, so I will have two alert conditions with the same configuration and name.

I believe the issue may be related to the initial apply not creating state correctly... running terraform state show newrelic_infra_alert_condition.rabbitmq_server_offline returns nothing, which would then make the recreation of the resources make sense.

Interestingly, if I do a terraform destroy targeting the resource, it removes all duplicates when it is destroyed, so there is some awareness that there are duplicate resources being created.

Expected Behavior

After the initial terraform apply, nothing should happen and no resources should get created.

Actual Behavior

Duplicate resources are created.

Steps to Reproduce

  1. terraform apply

Notes

My remote state is being stored in an S3 bucket.

Support for newrelic_nrql_ alert_condition "since_value" values greater than 5

newrelic_nrql_ alert_condition validation for the "since_value" attribute accepts values between 1-5. This attribute (now) supports values up to 20.

This attribute controls the evaluation offset of the nrql alert condition.

Terraform Version

Terraform v0.11.13
provider.newrelic v1.5.0

Affected Resource(s)

  • newrelic_nrql_ alert_condition

Terraform Configuration Files

An example of a resource where this happens:

resource "newrelic_nrql_alert_condition" "test" {
  policy_id   = "${newrelic_alert_policy.warning_policy.id}"
  name        = "test"

  term {
    duration      = 5
    threshold     = 0
    priority      = "critical"
    operator      = "above"
    time_function = "any"
  }

  nrql {
    query       = "SELECT sum(provider.errors.Maximum) from ServerlessSample FACET provider.functionName"
    since_value = "15"
  }
}

Expected Behavior

Terraform Plan should succeed

Actual Behavior

Terraform Plan fails:
newrelic_nrql_alert_condition.lambda_error_warning: expected nrql.0.since_value to be one of [1 2 3 4 5], got 15

Steps to Reproduce

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

  1. terraform apply

Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

[provider - newrelic] newrelic_alert_condition shows drift after applying

This issue was originally opened by @pickgr as hashicorp/terraform#11317. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

$ terraform -v
Terraform v0.8.4

Affected Resource(s)

newrelic_alert_condition

Terraform Configuration Files

resource "newrelic_alert_condition" "error_critical" {
  policy_id = "${newrelic_alert_policy.critical.id}"

  name        = "Errors critical"
  type        = "apm_app_metric"
  entities    = ["${data.newrelic_application.foo.id}", "${data.newrelic_application.bar.id}", "${data.newrelic_application.bam.id}"]
  metric      = "error_percentage"
  runbook_url = "${var.runbook_url}"

  term {
    duration      = 5
    operator      = "above"
    priority      = "critical"
    threshold     = "5"
    time_function = "all"
  }

  term {
    duration      = 10
    operator      = "above"
    priority      = "warning"
    threshold     = "1"
    time_function = "all"
  }
}

Expected Behavior

Configuration should apply successfully creating the alert condition. Subsequent "terraform plan" should show no drift (diff)

Actual Behavior

The following diff is shown when running plan after apply:

~ newrelic_alert_condition.error_critical
    term.0.duration:  "10" => "5"
    term.0.priority:  "warning" => "critical"
    term.0.threshold: "1" => "5"
    term.1.duration:  "5" => "10"
    term.1.priority:  "critical" => "warning"
    term.1.threshold: "5" => "1"

Steps to Reproduce

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

  1. terraform apply
  2. terraform plan

It's unknown if the NewRelic API returns the terms in a different order or how to reproduce this. There are other alert conditions not showing drift. Perhaps they just need to be sorted.

Perpetual drift in alert conditions with multiple entities

Terraform Version

Terraform v0.11.11

  • provider.newrelic v1.5.0

Affected Resource(s)

newrelic_alert_condition

Terraform Configuration Files

resource "newrelic_alert_condition" foo" {
  condition_scope = "application"

  entities = [
    "${data.newrelic_application.app1.id}",
    "${data.newrelic_application.app2.id}",
    "${data.newrelic_application.app3id}",
  ]

  # BUG? These seem to get re-ordered
  lifecycle {
    ignore_changes = ["entities"]
  }

  metric    = "apdex"
  name      = "Apdex (Low)"
  policy_id = "${data.terraform_remote_state.nr_monitoring.ops_policy_id}"

  term {
    duration      = 10
    operator      = "below"
    priority      = "critical"
    threshold     = "0.7"
    time_function = "all"
  }

  term {
    duration      = 30
    operator      = "below"
    priority      = "warning"
    threshold     = "0.85"
    time_function = "all"
  }

  type = "apm_app_metric"
}

Expected Behavior

The resource should get created successfully and subsequent applies should not show any drift.

Actual Behavior

Subsequent apply shows something like:

~ newrelic_alert_condition.error_percentage_slack
entities.0: "31315057" => "2206646"
entities.1: "2206646" => "90873514"
entities.2: "90873514" => "31315057"

Steps to Reproduce

  1. terraform apply
  2. terrafrom plan

Important Factoids

There's a work-around listed above in the code to ignore changes for the entities. This makes it difficult to modify the entities list though

NR entity IDs are now 64 bit integers

Terraform Version

v0.9.6

Affected Resource(s)

  • newrelic_alert_condition

I don't know of the schema helper in core is included is this issue.

Terraform Configuration Files

nr_alert.tf

variable "newrelic_api_key" {
}

# Configure the New Relic provider
provider "newrelic" {
  api_key = "${var.newrelic_api_key}"
}

# Create an alert policy
resource "newrelic_alert_policy" "alert" {
  name = "Rogneby Test"
}

# Add a condition
resource "newrelic_alert_condition" "foo" {
  policy_id = "${newrelic_alert_policy.alert.id}"

  name        = "tribble check"
  type        = "servers_metric"
  entities    = ["45021101"]                             # You can look this up in New Relic
  metric      = "cpu_percentage"
  runbook_url = "https://github.com/nobody/runbooks/"

  term {
    duration      = 5
    operator      = "below"
    priority      = "critical"
    threshold     = ".50"
    time_function = "all"
  }
}

# Add a notification channel
resource "newrelic_alert_channel" "email" {
  name = "Rogneby"
  type = "email"

  configuration = {
    recipients              = "[email protected]"
    include_json_attachment = "1"
  }
}

# Link the channel to the policy
resource "newrelic_alert_policy_channel" "alert_email" {
  policy_id  = "${newrelic_alert_policy.alert.id}"
  channel_id = "${newrelic_alert_channel.email.id}"
}

terraform.tsfstate for the alert_condition after first run

(which was successful) Notice that the entity ID returned and stored is 64bit instead of 32bit.

"newrelic_alert_condition.foo": {
                    "type": "newrelic_alert_condition",
                    "depends_on": [
                        "newrelic_alert_policy.alert"
                    ],
                    "primary": {
                        "id": "79080:382410",
                        "attributes": {
                            "condition_scope": "",
                            "entities.#": "1",
                            "entities.0": "1467454535970070007",
                            "id": "79080:382410",
                            "metric": "cpu_percentage",
                            "name": "tribble check",
                            "policy_id": "79080",
                            "runbook_url": "https://github.com/nobody/runbooks/",
                            "term.#": "1",
                            "term.0.duration": "5",
                            "term.0.operator": "below",
                            "term.0.priority": "critical",
                            "term.0.threshold": "0.50",
                            "term.0.time_function": "all",
                            "type": "servers_metric",
                            "user_defined_metric": "",
                            "user_defined_value_function": ""
                        },
                        "meta": {},
                        "tainted": false
                    },
                    "deposed": [],
                    "provider": ""
                }

Debug Output - second apply fails

terraform apply -var "newrelic_api_key=$NR_API_KEY"
newrelic_alert_policy.alert: Refreshing state... (ID: 79080)
newrelic_alert_channel.email: Refreshing state... (ID: 285005)
newrelic_alert_condition.foo: Refreshing state... (ID: 79080:382410)
newrelic_alert_policy_channel.alert_email: Refreshing state... (ID: 79080:285005)
Error refreshing state: 1 error(s) occurred:

* newrelic_alert_condition.foo: 1 error(s) occurred:

* newrelic_alert_condition.foo: newrelic_alert_condition.foo: strconv.ParseInt: parsing "1467454535970070007": value out of range

Panic Output

no panic.

Expected Behavior

the provider should accept a 64bit integer and not error out. with the launch in NR infrastructure entity IDs are 64bit now. It looks like there is some backwards compatibility to request with a mapped 32 bit ID but it returns the 64bit in the result.

Actual Behavior

Out of range error on the entity ID.

Steps to Reproduce

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

  1. terraform apply -var "newrelic_api_key=$NR_API_KEY"
  2. change something like the threshold in the alert condition.
  3. re-run terraform apply -var "newrelic_api_key=$NR_API_KEY"

Important Factoids

We are using the newelic_infra agent on our servers. not the old newrelic server agent.

References

none that I know of. This repo looks new.

Cannot create newrelic_alert_condition due to absence of violation_close_timer

Hi there,

Terraform Version

I'm using Terraform v0.10.6

Affected Resource(s)

  • newrelic_alert_condition

Terraform Configuration Files

  policy_id                   = "${newrelic_alert_policy.some_threadpool_alert_policy.id}"
  name                        = "${upper(terraform.workspace)}_Some_Threads"
  type                        = "apm_app_metric"
  entities                    = ["${data.newrelic_application.some_app.id}"]
  metric                      = "user_defined"
  condition_scope             = "instance"
  user_defined_metric         = "JmxBuiltIn/ThreadPool/\"some-thread-pool\"/Active"
  user_defined_value_function = "average"

  term {
    duration      = 5
    operator      = "above"
    priority      = "warning"
    threshold     = "150"
    time_function = "all"
  }

  term {
    duration      = 5
    operator      = "above"
    priority      = "critical"
    threshold     = "170"
    time_function = "all"
  }
}

Expected Behaviour

The terraform plan came back clean, so I was not expecting any issues when running the apply. The apply should have created the newrelic_alert_condition.

Actual Behaviour

All other terraform new relic resources were created correctly, but all of my newrelic_alert_condition resources failed with the message

* newrelic_alert_condition.some_threadpool_alert_condition: 1 error(s) occurred: newrelic_alert_condition.some_threadpool_alert_condition: `violation_close_timer` (in hours) must be present and one of: 1, 2, 4, 8, 12, 24.

I attempted to add violation_close_timer to the config, thinking that it was a config parameter that I missed off, but when I reran plan I got this message:
newrelic_alert_condition.some_threadpool_alert_condition: : invalid or unknown key: violation_close_timer

I then attempted to add violation_close_timer inside the term declaration, but when I reran the plan I got this message:

newrelic_alert_condition.some_threadpool_alert_condition: term.0: invalid or unknown key: violation_close_timer

Steps to Reproduce

  1. terraform apply

terraform import suggestion for newrelic_alert_channel has a typo

Terraform Version

Terraform v0.11.11

  • provider.newrelic v1.2.0

Expected Behavior

What should have happened?

Error: resource address "newrelic_alert_channel.foo" does not exist in the configuration.

Before importing this resource, please create its configuration in the root module. For example:

resource "newrelic_alert_channel" "foo" {
  # (resource arguments)
}

Actual Behavior

The name of the resource is incorrectly displayed, there is a typo in "newrelic_alerts_channel.foo"

Error: resource address "newrelic_alerts_channel.foo" does not exist in the configuration.

Before importing this resource, please create its configuration in the root module. For example:

resource "newrelic_alerts_channel" "foo" {
  # (resource arguments)
}

Steps to Reproduce

With the newrelic_alert_channel.foo NOT defined in the .tf file:
terraform import newrelic_alert_channel.foo 12345

Support for newrelic_alert_condition of type "NRQL QUERY"

Terraform Version

Terraform v0.9.8

Affected Resource(s)

newrelic_alert_condition

screen shot 2017-06-22 at 5 29 08 pm

Terraform Configuration Files

# Configure the New Relic provider
provider "newrelic" {
  api_key = "${var.newrelic_api_key}"
}

# Create an alert policy to apply for different objects
resource "newrelic_alert_policy" "alert" {
  name = "General_Alert"
}

Expected Behavior

Support for type "NRQL QUERY"

# Add condition 
resource "condition" "foo" {
  policy_id = "${newrelic_alert_policy.foo.id}"

  name        = "bar"

  term {
    duration      = 60
    operator      = "above"
    priority      = "critical"
    threshold     = "0"
    time_function = "all"
  }

  nrql {
    query = "SELECT count(*) from SyntheticCheck where monitorName = 'foo' and result != 'SUCCESS'"
    since_value = 3
  }

  value_fuinction = single_value
}

Actual Behavior

Type is not supported. There is no for alarm condition type option and other corresponding data source types for NRQL QUERY.

Important Factoids

See https://github.com/hashicorp/terraform/blob/950e24bc049bfaa6858fec2e09e38ab857cbfddf/builtin/providers/newrelic/resource_newrelic_alert_condition.go#L13
for types.
Similar enhancement issue seen in hashicorp/terraform#13516 for another alarming type

Modifying an alert policy recreates resource

Terraform Version

0.11.8

Affected Resource(s)

  • newrelic_alert_policy

Terraform Configuration Files

Initial config

resource "newrelic_alert_policy" "policy" {
  name                = "Alert Policy"
}

Update alert policy

resource "newrelic_alert_policy" "policy" {
  name                = "Alert Policy"
  incident_preference = "PER_CONDITION_AND_TARGET"
}

Expected Behavior

Alert policy should be updated

Actual Behavior

Alert policy is recreated, losing all created alert conditions

newrelic_alert_condition fails when no infrastructure exists in account

Terraform Version

Terraform v0.11.11

  • provider.newrelic v1.4.0

Affected Resource(s)

newrelic_alert_condition

Terraform Configuration Files

resource "newrelic_infra_alert_condition" "host_not_reporting" {
  policy_id = "${newrelic_alert_policy.infra_policy.id}"

  name       = "Host Not Reporting"
  type       = "infra_host_not_reporting"

  critical {
    duration      = 5
  }
}

Debug Output

https://gist.github.com/AshleyPoole/c4e8a9f47260e3fb16a501745082d7df

Expected Behavior

Alert condition is created but allocated against no resources.

Actual Behavior

Received an error instead as couldn't parse empty entries.
newrelic_alert_condition.apdex: entities.0: cannot parse '' as int: strconv.ParseInt: parsing "": invalid syntax

Steps to Reproduce

  1. terraform plan

Important Factoids

No infrastructure exist in New Relic when running the plan.

References

Base newrelic api golang library

Hi there,
Just reviewing the newrelic provider to undertaken some further development and I'm wanting to know of Hashicorp / Community perspectives on the newrelic provider options.

At the moment the provider is using https://github.com/paultyng/go-newrelic/ however that has no build checks to ensure that the library is stable.

https://github.com/yfronto/newrelic is older by a few months and with better docs.

Was there a design decision in adoping paultyng/go-newrelic ? If so, should I look to PR into that project (including getting automated testing with travis, README.md etc)?

Cheers!

Support newrelic partnership APIs

Terraform Version

# terraform version
Terraform v0.11.13
+ provider.newrelic v1.5.0

Affected Resource(s)

  • newrelic_partnership_account
  • newrelic_partnership_sub_account
  • newrelic_partnership_user

Terraform Configuration Files

Draft configuration example:

This is not yet supported

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.

data newrelic_product apm_pro_host {
  name = "APM"
  level = "Pro (Host)"
}

data newrelic_product mobile_lite {
  name = "Mobile"
  level = "Lite"
}

resource newrelic_partnership_account test {
  name = "my_test_account"
  partner_id = "123456"

  region = "eu"

  owner {
    email = "[email protected]"
    password = "XXXXXX"
    first_name = "Sample"
    last_name = "User"
  }

  subscription {
    product_id = "${data.newrelic_product.apm_pro_host.id}"
    quantity = "10"
  }

  subscription {
    product_id = "${data.newrelic_product.mobile_lite.id}"
    quantity = "0"
  }
}

resource newrelic_partnership_user test {
  account = "${newrelic_partnership_account.test.id}"

  email = "[email protected]"
  password = "XXXXXX"
  first_name = "Sample"
  last_name = "User"
  role = "admin"
  owner = "false"
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior

What should have happened?

The resources exposed via NewRelic's partnership API are available as terraform resources.

Actual Behavior

What actually happened?

None of the resources exposed via NewRelic's partnership API are available.

Steps to Reproduce

N/A

Important Factoids

N/A

References

NewRelic Partnership API reference:

The Newrelic endpoints used must be configurable, currently known public ones are:

https://docs.newrelic.com/docs/using-new-relic/welcome-new-relic/getting-started/introduction-eu-region-data-center#regions-availability

New policy and condition defaults policy_id to zero instead of <computed>

Terraform Version

0.11.7

Affected Resource(s)

Of what I've tested:

  • newrelic_alert_policy
  • newrelic_alert_condition
  • newrelic_infra_alert_condition

Possibly a core issue — not familiar with terraform's internals.

Terraform Configuration Files

A distilled example:

resource "newrelic_alert_policy" "app" {
  name = "app"
}

resource "newrelic_infra_alert_condition" "high_cpu_usage" {
  policy_id = "${newrelic_alert_policy.app.id}"

  name          = "High CPU usage"
  type          = "infra_metric"
  event         = "SystemSample"
  select        = "cpuPercent"
  comparison    = "above"

  critical {
    duration      = "2"
    value         = "80"
    time_function = "all"
  }
}

Expected Behavior

The alert condition to be created indicates policy_id => <computed>.

Actual Behavior

The alert condition to be created indicates policy_id => "0":

  + newrelic_infra_alert_condition.high_cpu_usage
      id:                       <computed>
      comparison:               "above"
      created_at:               <computed>
      critical.#:               "1"
      critical.0.duration:      "2"
      critical.0.time_function: "all"
      critical.0.value:         "80"
      enabled:                  "true"
      event:                    "SystemSample"
      name:                     "High CPU usage"
      policy_id:                "0"
      select:                   "cpuPercent"
      type:                     "infra_metric"
      updated_at:               <computed>

If applied, the creation of the condition fails (since the policy does not exist). On a second terraform apply, the policy_id is correct.

Steps to Reproduce

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

  1. terraform plan
  2. terraform apply x2 (fails to create the condition the first time, succeeds the second time.)

Any insights welcome here. Thanks!

newrelic_alert_channel with type=user is invalid

Terraform Version

Terraform v0.11.11

  • provider.newrelic v1.5.0

Affected Resource(s)

newrelic_alert_channel

Terraform Configuration Files

resource "newrelic_alert_channel" "user_john" {
  name = "user_john"
  type = "user"

  configuration = {
    user_id = "john"
  }
}

Debug Output

newrelic_alert_channel.user_john: Creating...
configuration.%: "" => "1"
configuration.user_id: "" => ""
name: "" => "user_john"
type: "" => "user"
Releasing state lock. This may take a few moments...

Error: Error applying plan:

1 error(s) occurred:

  • newrelic_alert_channel.user_john: 1 error(s) occurred:

  • newrelic_alert_channel.user_john: Invalid channel type

Expected Behavior

New alert channel of type user should be created successfully.

Actual Behavior

See output above

Steps to Reproduce

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

  1. terraform plan (works OK)
  2. terraform apply (fails)

Important Factoids

I do see a reference in the code here:

https://github.com/terraform-providers/terraform-provider-newrelic/blob/master/newrelic/resource_newrelic_alert_channel.go#L41

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here?
Not aware of any, but the documentation also does not list it.

Deleted Alert Policy causes unrecoverable error

Terraform Version

0.11.8

Affected Resource(s)

  • newrelic_alert_condition
  • newrelic_infra_alert_condition
  • newrelic_nrql_alert_condition
  • newrelic_synthetics_alert_condition

Expected Behavior

Alert conditions should be recreated if the policy does not exist

Actual Behavior

Cannot progress past plan errors.

Steps to Reproduce

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

  1. Create an alert policy and conditions
  2. Delete alert policy via New Relic UI
  3. Run terraform plan
  4. Notice errors similar to newrelic_nrql_alert_condition.master_count_high: Alerts policy {ID} could not be found.

Support notes for newrelic_dashboard

Hey,

I would also like to create notes for a New Relic dashboard. I guess this functionality is not implemented yet. Would be nice to also have support for this :-)

Alerts policy not found during test

Terraform Version

Terraform v0.9.8

Affected Resource(s)

newrelic_alert_policy_channel

Terraform Configuration Files

resource "newrelic_alert_policy" "foo" {
  name = "tf-test-%[1]s"
}

resource "newrelic_alert_channel" "foo" {
  name = "tf-test-%[1]s"
	type = "email"
	
	configuration = {
		recipients = "[email protected]"
		include_json_attachment = "1"
	}
}

resource "newrelic_alert_policy_channel" "foo" {
  policy_id  = "${newrelic_alert_policy.foo.id}"
  channel_id = "${newrelic_alert_channel.foo.id}"
}

Debug Output

https://gist.github.com/RubyLi0612/5945cc7cf6c658d8b30da09561def4bc

Expected Behavior

Pass tests under github.com/terraform-providers/terraform-provider-newrelic/newrelic/

Actual Behavior

Test fail for creating new NewRelic alert policy channel:
screen shot 2017-07-05 at 2 18 11 pm

This only occur sometimes, while some time the test passes without error.

Steps to Reproduce

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

  1. cd github.com/terraform-providers/terraform-provider-newrelic/
  2. make fmt
  3. set NEWRELIC_API_KEY and NEWRELIC_LICENSE_KEY correctly
  4. make testacc

Important Factoids

The files are pulled from this repo unchanged. All imported files are also cloned from according repos.

violation_close_timer required but API does not require it

Hi,

Currently it is required to set the violation_close_timer for every newrelic_alert_condition: https://github.com/terraform-providers/terraform-provider-newrelic/blob/master/newrelic/resource_newrelic_alert_condition.go#L125
However the API documentation does not explicitly state this: https://docs.newrelic.com/docs/alerts/rest-api-alerts/new-relic-alerts-rest-api/alerts-conditions-api-field-names#field-names
Furthermore I contacted the NewRelic support regarding this. They said that this setting is only required for alerts with scope instance and for JVM health metrics.

Requiring this setting results in unnecessary changes like the following:

  ~ newrelic_alert_condition.acp_cs_Prod_Service_error_pct
      violation_close_timer: "0" => "24"

I would suggest to only require this setting when necessery. I can create a PR for this of you aggree.

Unable to specify payload for webhook in json

Terraform Version

Terraform v0.10.8

Affected Resource(s)

  • newrelic_alert_channel with type of webhook

Terraform Configuration Files

resource "newrelic_alert_channel" "webhooktest" {
  name = "webhooktest"
  type = "webhook"

  configuration = {
    payload_type    = "application/json"
    auth_username   = "my_user",
    auth_password   = "my_password",
    base_url        = "thirdpartyurl",
    payload         = {"priority": 3, "status": 2, "description": "New Relic Notification"}
  }
}

Expected Behavior

Create alert channel with payload in json format.

Actual Behavior

Error: Error parsing main.tf: At 28:34: illegal char

Steps to Reproduce

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

  1. terraform apply

Terms threshold reported blank when assigning zero to it

Terraform Version

Terraform v0.9.11

Affected Resource(s)

newrelic_alert_condition

Terraform Configuration Files

# Configure the New Relic provider
provider "newrelic" {
  api_key = "${var.newrelic_api_key}"
}

resource "newrelic_alert_policy" "alert" {
  name = "Policy"
}

Expected Behavior

Assign threshold of the condition to 0 successfully.

Actual Behavior

Error outputed as: Terms threshold can't be blank
image

Steps to Reproduce

terraform apply

Important Factoids

According to the documentation for terraform newrelic_alert_condition, threshold can be set to 0:
image
Yet assigning it to "0", 0, "0.0" all trigger the error.

Resource not found error running tests for creating new alert

Terraform Version

Terraform v0.9.8

Affected Resource(s)

newrelic_alert_condition
newrelic_alert_channel

Terraform Configuration Files

resource "newrelic_alert_policy" "foo" {
  name = "tf-test-nrql-%[1]s"
}

resource "newrelic_alert_condition" "foo" {
  policy_id = "${newrelic_alert_policy.foo.id}"
  name            = "tf-test-nrql-%[1]s"
  type            = "nrql_query"
  runbook_url     = "https://foo.example.com"

  term {
    duration      = 5
    operator      = "below"
    priority      = "critical"
    threshold     = "0.75"
    time_function = "all"
  }

  nrql {
    query = "SELECT count(*) from SyntheticCheck where monitorName = 'foo' and result != 'SUCCESS'"
    since_value = 3
  }

  value_function = "single_value"
}

Debug Output

https://gist.github.com/RubyLi0612/0c5922d1bc90fcef66c586e9efe7667a

Expected Behavior

Pass tests for creating new NewRelic alert conditions of type NRQL query.

Actual Behavior

outputed when running github.com/terraform-providers/terraform-provider-newrelic/newrelic/resource_newrelic_alert_condition_test.go: Step 2 error: Check failed: Check 1/13 error: newrelic: Resource not found
newrelic_alert_policy_channel.foo: Alerts policy 87391 could not be found.

Steps to Reproduce

Added implementations for NRQL query NewRelic alert condition inside github.com/terraform-providers/terraform-provider-newrelic/newrelic/resource_newrelic_alert_condition.go
Added test for NRQL query NewRelic alert condition inside github.com/terraform-providers/terraform-provider-newrelic/newrelic/resource_newrelic_alert_condition_test.go.
cd /github.com/terraform-providers/terraform-provider-newrelic/
make fmt
make testacc

Important Factoids

New condition type for NRQL is implemented in github.com/terraform-providers/terraform-provider-newrelic/newrelic/resource_newrelic_alert_condition.go
Used the same policy and condition resource as originally in test files to test newly implemented features.
NEWRELIC_API_KEY and NEWRELIC_LICENSE_KEY are set correctly according to my NewRelic account.

Alerts for Plugin Conditions

Good day,,

We started to maintain our configuration of New Relic in terraform, and up to now with the plugin version 1.0.1 its working great. However, we created some new relic plugins that provide custom metrics and I want to create custom alerts on these metrics:

The api is available:
https://docs.newrelic.com/docs/alerts/rest-api-alerts/new-relic-alerts-rest-api/rest-api-calls-new-relic-alerts#plugins-conditions but I cannot find if this feature is in the documentation.

Issue using import with newrelic provider

Terraform Version

$ terraform --version
Terraform v0.11.8

  • provider.newrelic v1.0.1

Affected Resource(s)

I'm sorry, I don't know how to answer this.

Terraform Configuration Files


resource "newrelic_alert_policy" "foo" {
  name = "foo"
}

resource "newrelic_infra_alert_condition" "foo" {
  policy_id = "${newrelic_alert_policy.foo.id}"

  name       = "High disk usage"
  type       = "infra_metric"
  event      = "StorageSample"
  select     = "diskUsedPercent"
  comparison = "above"
  where      = "(`hostname` LIKE '%frontend%')"

  critical {
    duration      = 25
    value         = 90
    time_function = "all"
  }
}

Debug Output

https://gist.github.com/ghstwhl/63354ee5834c0419efe972088328d394

Expected Behavior

The import command should have linked the existing NewRelic alert condition with the sample one in my config, and I could have then used plan to identify the changes necessary to match the existing check in the tf config.

Actual Behavior

The output first says the import completed, and it then says there was an error in parsing.

Steps to Reproduce

  1. copy the sample policy and check from https://www.terraform.io/docs/providers/newrelic/r/infra_alert_condition.html
  2. use terraform import to link the policy to an existing New Relic Policy.
  3. use terraform import to link the infra alert condition to an existing infrastructure alert.

Important Factoids

The existing policy and infra checks I am trying to import are pretty generic:

Policy:
    {
      "updated_at": 1532403275005, 
      "incident_preference": "PER_CONDITION_AND_TARGET", 
      "created_at": 1531787485573, 
      "id": 283153, 
      "name": "Alerts that go ping"
    }, 
    

Alert Condition:
{
  "comparison": "above", 
  "select_value": "memoryUsedBytes/memoryTotalBytes*100", 
  "created_at_epoch_millis": 1531794178903, 
  "name": "High Memory Utilization", 
  "enabled": true, 
  "filter": {
    "and": [
      {
        "is": {
          "windowsPlatform": "Microsoft Windows Server 2012 R2 Standard"
        }
      }, 
      {
        "is": {
          "ec2Tag_owner": "[email protected]"
        }
      }, 
      {
        "is": {
          "providerAccountName": "some-account"
        }
      }
    ]
  }, 
  "updated_at_epoch_millis": 1532403302548, 
  "event_type": "SystemSample", 
  "critical_threshold": {
    "duration_minutes": 15, 
    "value": 99.9, 
    "time_function": "all"
  }, 
  "type": "infra_metric", 
  "id": 5885249, 
  "policy_id": 283153
}, ```

Make resource_newrelic_alert_condition enabled status configurable

This issue was originally opened by @garthkerr as hashicorp/terraform#11123. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

v0.8.2

Affected Resource(s)

  • resource_newrelic_alert_condition

The newrelic resource module by @paultyng is outstanding thus far. However, is would be useful to make the enabled status a configurable argument:

https://github.com/hashicorp/terraform/blob/3dfe5a47f1a2cb0df32f086b740bad89c028a9a2/builtin/providers/newrelic/resource_newrelic_alert_condition.go#L184

Automate the enablement of integration providers, e.g AWS

At the moment enabling integration provider, e.g. for AWS requires manual configuration under Infrastructure>Integrations. It does require the Amazon account id and role to assume for pulling out CloudWatch metrics.

It would nice to have a newrelic resource so that this can be automated given the fact that the below details are already known:

  • AccountID
  • Role to be assumed
  • External ID

newrelic_infra_alert_condition - add support for integration_provider

Terraform Version

terraform 0.11.7
newrelic provider 1.0.1

Affected Resource(s)

  • newrelic_infra_alert_condition

Terraform Configuration Files

resource "newrelic_infra_alert_condition" "elb_host_count" {
  policy_id = "${newrelic_alert_policy.alerting.id}"

  name       = "ELB Healthy Host Count"
  enabled    = true
  type       = "infra_metric"
  event      = "LoadBalancerSample"
  select     = "provider.healthyHostCount.Average"
  comparison = "below"
  where      = "(`ec2Tag_environment` = '${var.environment}')"

  critical {
    duration      = 10
    value         = 1
    time_function = "all"
  }
}

Expected Behaviour

The result should be a working alert condition for ELB integration in NewRelic.

Actual Behaviour

The created alert condition doesn't pick up and display the metric from ELB. The displayed graph is empty in contrast to a manually configured alert.

image

Important Factoids

Querying the REST API shows that there is a need for additional argument for AWS ELB integration called integration_provider which is missing (or not available now ).

{
  "data": [
    {
      "type": "infra_metric",
      "name": "elb",
      "enabled": true,
      "filter": {
        "and": [
          {
            "is": {
              "provider.elbTag_environment": "prod"
            }
          }
        ]
      },
      "id": 6304632,
      "created_at_epoch_millis": 1532542213665,
      "updated_at_epoch_millis": 1532542213736,
      "policy_id": 287280,
      "event_type": "LoadBalancerSample",
      "select_value": "provider.healthyHostCount.Average",
      "comparison": "below",
      "critical_threshold": {
        "value": 1,
        "duration_minutes": 10,
        "time_function": "all"
      },
      "integration_provider": "Elb"
    },

Support for newrelic_alert_condition of type "synthetics monitor failure"

This issue was originally opened by @pickgr as hashicorp/terraform#13516. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

0.8.8

Affected Resource(s)

newrelic_alert_condition
staging_policy_-_alerts_by_new_relic

Expected Behavior

Support for type "synthetics monitor failure"

Actual Behavior

Type is not supported

Errors:

  * newrelic_alert_condition.ping_staging: expected type to be one of [apm_app_metric apm_kt_metric browser_metric mobile_metric servers_metric], got synthetics_monitor_failure

Important Factoids

See https://github.com/hashicorp/terraform/blob/950e24bc049bfaa6858fec2e09e38ab857cbfddf/builtin/providers/newrelic/resource_newrelic_alert_condition.go#L13
for types.

Manage Browser Agent Configurations

Use Case

the use case for using terraform to create Browser SPA in New Relic is that my customer hosts a number of customers and they want each of these customer instances to have New Relic monitoring. It would be much easier if they can use Terraform to spin up a Browser SPA app in New Relic instead of using the UI to add new apps.

The particular customer add about 10 to 30 customers per week so you can imagine how much simpler it would be to automate this.

To allow configuring and setup of Browser agent configurations. API documentation: https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api
https://rpm.newrelic.com/api/explore/browser_applications/create

Wrong Type used in newrelic_alert_channel webhook configuration

Hi there,

Noticed that a wrong type was used for keys payload and headers in the web hook configuration

Got an error that payload and headers should be string which is not so according to the API documentation with example below

{
  "base_url": "http://test.com",
  "auth_username": "username",
  "auth_password": "password",
  "payload_type": "application/json",
  "payload": {"account_id": 1, "account_name": "account name" },
  "headers": {"header1": "test", "header2": "test"}
}

Terraform Version

v0.11.10

Affected Resource(s)

Please list the resources as a list, for example:

  • newrelic_alert_channel

Debug Output

2018-11-14T12:54:29.861+0400 [DEBUG] plugin.terraform-provider-newrelic_v1.2.0_x4: 2018/11/14 12:54:29 [INFO] Reading New Relic alert channel 2024412
2018/11/14 12:54:32 [ERROR] root: eval: *terraform.EvalRefresh, err: newrelic_alert_channel.this: [DEBUG] Error setting Alert Channel Configuration: &errors.errorString{s:"configuration.payload: '' expected type 'string', got unconvertible type 'map[string]interface {}'"}
2018/11/14 12:54:32 [ERROR] root: eval: *terraform.EvalSequence, err: newrelic_alert_channel.this: [DEBUG] Error setting Alert Channel Configuration: &errors.errorString{s:"configuration.payload: '' expected type 'string', got unconvertible type 'map[string]interface {}'"}
2018/11/14 12:54:32 [TRACE] [walkRefresh] Exiting eval tree: newrelic_alert_channel.this

2018/11/14 12:54:32 [DEBUG] plugin: waiting for all plugin processes to complete...
Error: Error refreshing state: 1 error(s) occurred:

2018-11-14T12:54:32.015+0400 [DEBUG] plugin.terraform-provider-newrelic_v1.2.0_x4: 2018/11/14 12:54:32 [ERR] plugin: plugin server: accept unix /var/folders/mr/6gwkzzjs4nldgm7gf2dbj6yw0000gn/T/plugin499091540: use of closed network connection
2018-11-14T12:54:32.015+0400 [DEBUG] plugin.terraform-provider-aws_v1.43.2_x4: 2018/11/14 12:54:32 [ERR] plugin: plugin server: accept unix /var/folders/mr/6gwkzzjs4nldgm7gf2dbj6yw0000gn/T/plugin205253133: use of closed network connection
* newrelic_alert_channel.this: 1 error(s) occurred:

2018-11-14T12:54:32.018+0400 [DEBUG] plugin: plugin process exited: path=/Users/oba/.terraform.d/plugins/darwin_amd64/terraform-provider-newrelic_v1.2.0_x4
2018-11-14T12:54:32.019+0400 [DEBUG] plugin: plugin process exited: path=/Users/oba/.terraform.d/plugins/darwin_amd64/terraform-provider-aws_v1.43.2_x4
* newrelic_alert_channel.this: newrelic_alert_channel.this: [DEBUG] Error setting Alert Channel Configuration: &errors.errorString{s:"configuration.payload: '' expected type 'string', got unconvertible type 'map[string]interface {}'"}

Expected Behavior

payload and headers should be a map

Steps to Reproduce

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

  1. create main.tf
resource "newrelic_alert_channel" "this" {
  name     = "example"
  type     = "webhook"

  configuration = {
    base_url     = "https://example.com/runbook_url"
    payload_type = "application/json"
    payload      = "${map("account_id","$ACCOUNT_ID")}"
    headers      = "${map("X-Insert-Key","my_key")}"
  }
}
  1. terraform apply

provider/newrelic: newrelic_alert_channel continually recreates resources

This issue was originally opened by @silvamerica as hashicorp/terraform#13401. It was migrated here as part of the provider split. The original body of the issue is below.


Terraform Version

0.9.2

Affected Resource(s)

  • newrelic_alert_channel
  • newrelic_alert_policy_channel

Terraform Configuration Files

resource "newrelic_alert_policy" "alerting" {
  name = "${var.name}-${var.environment}"
}

resource "newrelic_alert_channel" "alerting" {
  name = "${var.name}-pagerduty-${var.environment}"
  type = "pagerduty"

  configuration = {
    subdomain = "${var.subdomain}"
    service_name = "${pagerduty_service_integration.newrelic.name}"
    service_key = "${pagerduty_service_integration.newrelic.integration_key}"
  }
}

resource "newrelic_alert_policy_channel" "alerting" {
  policy_id  = "${newrelic_alert_policy.alerting.id}"
  channel_id = "${newrelic_alert_channel.alerting.id}"
}

Expected Behavior

No changes should be detected

Actual Behavior

-/+ module.alerting.newrelic_alert_channel.alerting
    configuration.%:            "0" => "3" (forces new resource)
    configuration.service_key:  "<sensitive>" => "<sensitive>" (forces new resource)
    configuration.service_name: "<sensitive>" => "<sensitive>" (forces new resource)
    configuration.subdomain:    "<sensitive>" => "<sensitive>" (forces new resource)
    name:                       "alerting-pagerduty-production" => "alerting-pagerduty-production"
    type:                       "pagerduty" => "pagerduty"

-/+ module.alerting.newrelic_alert_policy_channel.alerting
    channel_id: "223790" => "0" (forces new resource)
    policy_id:  "57733" => "57733"

It seems like the configuration hash might not be being sent from the newrelic API, therefore the newrelic provider thinks it has to re-add it every time.

Panic encountered while running tests for creating NewRelic alert conditions

Terraform Version

Terraform v0.9.8

Affected Resource(s)

newrelic_alert_condition

Terraform Configuration Files

data "newrelic_application" "app" {
	name = "%[2]s"
}

resource "newrelic_alert_policy" "foo" {
  name = "tf-test-%[1]s"
}

resource "newrelic_alert_condition" "foo" {
  policy_id = "${newrelic_alert_policy.foo.id}"

  name            = "tf-test-%[1]s"
  type            = "apm_app_metric"
  entities        = ["${data.newrelic_application.app.id}"]
  metric          = "apdex"
  runbook_url     = "https://foo.example.com"
  condition_scope = "application"

  term {
    duration      = 5
    operator      = "below"
    priority      = "critical"
    threshold     = "0.75"
    time_function = "all"
  }
}

Created by terraform-provider-newrelic/newrelic/resource_newrelic_alert_condition_test.go

Panic Output

https://gist.github.com/RubyLi0612/7402e076e622003e8e4b4019aed22add

Expected Behavior

New NewRelic alert conditions are created successfully and tests pass for creating NewRelic alert conditions.

Actual Behavior

Encounter panic when running tests under /github.com/terraform-providers/terraform-provider-newrelic/newrelic/
screen shot 2017-06-30 at 12 04 55 pm

Steps to Reproduce

cd /github.com/terraform-providers/terraform-provider-newrelic/newrelic/
make fmt
make testacc

Important Factoids

I have set the newrelic api key to the api key of my NewRelic account under Admin’s API key section. License key is also the correct license key of my NewRelic account.

Unable to create a gauge-widget on a newrelic dashboard

Hi,

I'm using terraform version v0.11.7 with provider.newrelic v1.0.0

when applying the following code-snippet, it results in an Internal Server Error
widget {
title = "Pending messages"
row = 1
column = 2
visualization = "gauge"
nrql = "SELECT latest(pending_message_count) FROM message_server"
}

If i change gauge to billboard or billboard-comparison, it works.

There is also no attribute to set the gauge-limit.

Please fix

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.