v0.11.8
newrelic_application data sourcenewrelic_alert_condition resourceConsider the case where:
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.
N/A
N/A
See _Terraform Configuration Files_ above
See _Terraform Configuration Files_ above
See _Terraform Configuration Files_ above
See _Terraform Configuration Files_ above
I don't this this is an issue with the provider, I think it's an issue with how you're using it. The terraform provider checks for existing applications, if the application doesn't exist the best thing to do would be to break out the application creation into a separate terraform file or process and create it prior to trying to use the New Relic resource in one of your TF files.
I was told at one point there is no API call to create an APM app, as it requires running the app in the APM Agent.
I work for New Relic, this is currently true.
As a workaround, you can either spin up an application with the newrelic agent for whatever name you want to create and spin it back down (we have a nodejs cli tool for this) or just impersonate the agent registration APM call. The former is much easier, but definitely not as clean.
I really don't understand why New Relic doesn't have an API call to create an application, since it is possible to work around.
The above is all correct. I will open a feature request for a REST V2 API endpoint for creating applications, as this workflow will become increasingly common. Closing this issue for now.
Most helpful comment
The above is all correct. I will open a feature request for a REST V2 API endpoint for creating applications, as this workflow will become increasingly common. Closing this issue for now.