newrelic / terraform-provider-newrelic

Terraform provider for New Relic
https://registry.terraform.io/providers/newrelic/newrelic/latest/docs
Mozilla Public License 2.0
201 stars 244 forks source link

Cannot set Node 10 (Legacy) runtime on new `newrelic_synthetics_script_monitor` resource #2077

Closed arhill05 closed 1 year ago

arhill05 commented 1 year ago

Hi there,

Please include the following with your bug report

:warning: Important: Failure to include the following, such as omitting the Terraform configuration in question, may delay resolving the issue.

Terraform Version

Terraform v1.3.3

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration

Please include your provider configuration (sensitive details redacted) as well as the configuration of the resources and/or data sources related to the bug report.


terraform {
required_providers {
newrelic = {
source  = "newrelic/newrelic"
version = "3.6.0"
}
}
}

provider "newrelic" { api_key = var.api_key account_id = var.account_id region = "US" }

resource "newrelic_synthetics_script_monitor" "canary_synthetic_monitor" { account_id = var.account_id for_each = { for app in var.apps : app.monitor_name => app }

period = "EVERY_10_MINUTES" location_private { guid = data.newrelic_synthetics_private_location.louisville.id }

name = "TF_${each.value.monitor_name}" runtime_type = "NODE_API" runtime_type_version = "10.15" status = coalesce(each.value.is_enabled, true) ? "ENABLED" : "DISABLED" type = "SCRIPT_API"

tag { key = "environment" values = ["${var.environment}"] }

tag { key = "server-group" values = [coalesce(each.value.server_group, "UNKNOWN")] }

tag { key = "managed-by-terraform" values = [true] }

script_language = "JAVASCRIPT" script = templatefile( "${path.module}/synthetics-scripts/${coalesce(each.value.custom_canary_script_name, "default.jstpl")}", { app = each.value }) }



### Actual Behavior
An error occurs

### Expected Behavior
The synthetic monitor should be created with the script content and the runtime set to (Node 10 (Legacy))

### Steps to Reproduce
1. Set `runtime_type_version` to `10.15` (or any other 10.x Node version) and `runtime_type` to `NODE_API` on the `newrelic_synthetics_script_monitor` resource
2. `terraform apply`

### Debug Output
https://gist.github.com/arhill05/a66381a7f5bc2f92d0ac96c1f36fefc8

### Important Factoids
I've versions 10.0 -> 10.16, but nothing works.

Furthermore, the state believes the `apply` was successful after this error, because a subsequent `terraform plan` shows there are no further changes to be made.
arhill05 commented 1 year ago

Well as is true any time I open an issue, I found a workaround right after opening it. #2062 shows that you can remove the script_language, runtime_type and runtime_type_version attributes to use the legacy runtime version even though the documentation identifies those properties as required.

If this was properly documented it would've saved me a day's worth of a headache :D

Can the documentation be updated to reflect this behavior?

NSSPKrishna commented 1 year ago

Hi @arhill05, sorry for causing the confusion. Will update the document.

NSSPKrishna commented 1 year ago

The docs are updated ( link ). If you feel the issue is still valid, feel free to raise a new issue.