Synthetic Labels End of Life for TF New Relic Provider

How can we prepare for the End of Life for Synthetic Labels if we are using the Terraform New Relic Provider to manage our Synthetics.

Just logged a Feature Request in the GitHub repo for this as well: https://github.com/terraform-providers/terraform-provider-newrelic/issues/666 and I did get some feedback that this is already something being worked-on for v2

1 Like

@allan.bernardo

Thanks for posting to the Github repo! That’s the best place for reports like this to get directly in touch with developers.

Glad you got an update there, and thanks for following up here with that.

@allan.bernardo This functionality has been superseded by the new newrelic_entity data source and newrelic_entity_tags resource added in v2 of the provider. Synthetics monitors can be targeted by using a MONITOR type and SYNTH domain when configuring your data sources. Please try it out and let us know how it goes!

1 Like

Thank you for the heads-up. I have line up some work for us to replace all our Synthetic Label resources with the Entity Tags. Will let you know how that goes.

1 Like

Looking forward to hearing how it goes for you :smiley:

I’m having problems adding tags to a newrelic_synthetics_monitor.

The example below returns an error because during refresh phase, data is not available because newrelic_synthetics_monitor is not created yet.

If I add a depends_on to data, it will fail on first run, and run successfully on second.

How do I manage to have this running successfully in one run? Is it possible to implement on newrelic_synthetics_monitor to return its entity GUID in addition to ID?

resource "newrelic_synthetics_monitor" "ssl" {
  name          = var.name
  type          = "SCRIPT_API"
  frequency     = var.frequency
  status        = var.status
  locations     = var.locations
  sla_threshold = var.sla_threshold
}
data "newrelic_entity" "ssl" {
  name   = var.name
  type = "MONITOR"
  domain = "SYNTH"
}
resource "newrelic_entity_tags" "ssl" {
  guid = data.newrelic_entity.ssl.guid

  dynamic "tag" {
    for_each = merge(var.tags, local.common_tags)
    content {
      key    = tag.key
      values = list(tag.value)
    }
  }
}
1 Like

BTW: https://github.com/newrelic/terraform-provider-newrelic/issues/756

Thanks for posting on Github @w.sartorijunior - That’s the best place for the folks who built our terraform provider to see that and help out :slight_smile:

I have just updated one of our Sub-Modules that uses Synthetic Labels with the new Entity Tags and after some fiddling on the proper looping logic to create the nested tag block I am happy to say that everything is working as expected. I will continue to move the rest of our sub-modules to use the Entity Tags.

3 Likes

That’s great! Thanks for that update :smiley:

@allan.bernardo, is it creating the synthetic monitor and adding the entity tags in the first apply without errors? Would you mind sharing what you did?

@w.sartorijunior, I have yet to test the scenario wherein I have a new monitor to create and then add the tags to that since our monitors were already existing and we are just moving from labels to tags. I did notice some weird behavior on TF Plan when I used the same looping logic I used for labels. I actually wanted to thank you since I followed your use of the dynamic block to create the tags. Also, we use sub-modules wherein the monitor is created first then I use a datasource (passing-in the name I used to create the monitor) to get the entity id then I use the entity_tags. Something like this:

resource “newrelic_synthetics_monitor” “api_synthetic” {
name = var.name
type = “SCRIPT_API”
frequency = var.synthetic_frequency
status = var.synthetic_status
locations = var.synthetic_location
}

data “newrelic_entity” “entity” {
name = var.name
}

resource “newrelic_entity_tags” “tags” {
guid = data.newrelic_entity.entity.guid

dynamic “tag” {
for_each = var.tags
content {
key = tag.key
values = list(tag.value)
}
}
}

This is exactly my case. I’m afraid you’ll have the same problem when creating a new monitor due to newrelic_entity data depending on newrelic_synthetics_monitor resource that is not yet created. During the refresh phase the data will fail (that happens before TF plan or apply).

You are correct. I found something else too that is similar. I had to rename some of my existing synthetics and the new name does not get reflected right away in New Relic One so the entity_tag data source can’t see it.