-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
newrelic_entity_tags right after creating a resource #756
Comments
Hi @trunet ! We are in the middle of a large transition that involves moving most of our resources from legacy REST-based APIs to the NerdGraph GraphQL API. Synthetics is a domain that has not been moved yet, and for this reason we can't surface entity GUIDs directly after the monitor's creation. Once synthetic monitors surface in NerdGraph, we should be able to do exactly that. In the meantime, I wonder if the backend just needs a few seconds to index the new resource. Can you try adding a 10-30s sleep after monitor creation and see if the helps? https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep I know this is not ideal but it should be able to get you moving until Synthetics is moved into NerdGraph. |
@ctrombley this workaround works fine. I added a 10s sleep in between and it works flawless. For future reference if anyone face this problem: 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
}
resource "time_sleep" "wait_10_seconds" {
depends_on = [newrelic_synthetics_monitor.ssl]
create_duration = "10s"
}
data "newrelic_entity" "ssl" {
name = var.name
domain = "SYNTH"
depends_on = [time_sleep.wait_10_seconds]
}
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)
}
}
} |
I'm still having issues. The sleep 10 is not enough, and in my case, I got some synthetics that took 15 minutes to be able to have a GUID available. |
There's another problem, not sure if you want another ticket for this. If the data name is a constant (in my case var.name), it will ALWAYS try to get on refresh phase and trigger an error if you try to rename one monitor. If resource "newrelic_synthetics_monitor" "[REDACTED]_endtoend" {
name = var.name
type = "SCRIPT_BROWSER"
frequency = var.frequency
status = var.status
locations = var.locations
sla_threshold = var.sla_threshold
}
resource "time_sleep" "wait_10_seconds" {
depends_on = [newrelic_synthetics_monitor.reaxys_endtoend]
create_duration = "10s"
}
data "newrelic_entity" "[REDACTED]_endtoend" {
name = var.name
type = "MONITOR"
domain = "SYNTH"
depends_on = [time_sleep.wait_10_seconds, newrelic_synthetics_monitor.reaxys_endtoend]
} Error:
|
I manage to workaround this (once again), doing this: data "null_data_source" "name" {
inputs = {
name = var.name
}
depends_on = [time_sleep.wait_10_seconds]
}
data "newrelic_entity" "[REDACTED]_endtoend" {
name = data.null_data_source.name
type = "MONITOR"
domain = "SYNTH"
} |
@ctrombley - Is there updates on when NerdGraph GraphQL APIs will be available to fix this issue? Thanks for your reply. |
Is this still an issue with the latest release? I can't tell if this was the same issue as the service-defined tags, or slightly different. |
@zlesnr - This is still an issue since this was related to the fact that the newrelic_synthetics_monitor resource does not output an entity_guid after create. I think that's because the APIs for synthetics are still not in NERDGraph. Note: I did try using the latest provider version creating a new synthetic and assign a tag right away and still same error as above |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. |
This issue has been automatically closed due to a lack of activity for an extended period of time. |
This is definitely still an issue and should not be closed. |
I'm hearing that the synthetics resources may be available in Nerdgraph soon. |
That's great news @zlesnr. Please do keep us updated. |
Now using the |
That looks like a new issue to me @imsathyakumar. If so, please file a new issue. |
Just a note for anyone that's trying to implement this with for_each looped resource definitions. I found that even using @trunet's workaround with the time_sleep dependency I was still getting the error:
Works on first run but succeeds on subsequent runs. It look like the time_sleep dependency was not working properly, at least not for all resources in the loop. The following configuration seems to work: data "newrelic_entity" "synthetic_loop" {
for_each = {
for synthetic in local.synthetic:
synthetic.name => synthetic
}
name = time_sleep.wait_10_seconds_synthetic[each.value.name].triggers["name"]
domain = "SYNTH"
type = "MONITOR"
}
resource "time_sleep" "wait_10_seconds_synthetic" {
for_each = {
for synthetic in local.synthetic:
synthetic.name => synthetic
}
create_duration = "10s"
triggers = {
name = newrelic_synthetics_monitor.synthetic_loop[each.value.name].name
}
}
resource "newrelic_synthetics_monitor" "synthetic_loop" {
for_each = {
for synthetic in local.synthetic:
synthetic.name => synthetic
}
name = join(" ", [local.tags.policy_name, each.value.name])
type = each.value.type
frequency = each.value.frequency
status = each.value.enabled ? "ENABLED": "DISABLED"
locations = each.value.location
uri = each.value.uri
}
resource "newrelic_entity_tags" "synthetic_loop" {
for_each = {
for synthetic in local.synthetic:
synthetic.name => synthetic
}
guid = data.newrelic_entity.synthetic_loop[each.value.name].guid
dynamic "tag" {
for_each = local.tags
content {
key = tag.key
values = [tag.value]
}
}
}
The changes being:
|
Is there any timeline when would this be resolved? |
The new API's for synthetics should be available soon, and will plan in the work to migrate synthetics resources to the new API. No timeline at the moment. |
Just adding another voice of support for this issue - we ran into this exact same problem today. |
I would also like to vote for this issue. We ran into this same problem today. |
Running into same issue :( |
Just to add another voice to the queue to keep this active - our team is also looking for a way to manage tags on synthetics and plan on waiting for this fix before we do. |
Update from the team: We are currently in the process of migrating Synthetics to the new API's. So you can soon expect a better solution than |
That was the update from November 2021. Is there an ETA of when we can expect this migration to be complete? |
The update was indeed similar, at that time the new API was not yet available, now it is. We hope to have this all done before the summer. |
+1 for this issue |
We've released V3 version of our provider which includes all of the new Synthetics features: https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/guides/migration_guide_v3 The new resources now include a tags attribute which will allow you to set the right tags from the resource without the need for Please let us know if you have any questions. If you encounter any issues please don't hesitate to create a new ticket. I'll close this ticket as the work has been delivered. Feel free to continue the discussion if needed. |
Feature Description
To be able to use newrelic_entity_tags, we need to have the entity GUID. However, the resource is not yet created when data is acquired. We need to have a way to get GUID and/or resource name from the resource itself so data will auto depend on it during apply.
Describe Alternatives
Using depends_on on the data (that is not recommended on terraform documentation) and it will fail once and succeed on second run.
Additional context
From https://discuss.newrelic.com/t/synthetic-labels-end-of-life-for-tf-new-relic-provider/104468/6
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?
The text was updated successfully, but these errors were encountered: