• /
  • EnglishEspañolFrançais日本語한국어Português
  • Inicia sesiónComenzar ahora

Manage your workloads with Terraform

You can use Terraform to create, manage, and update your New Relic workloads, whether using intelligent workloads to track important business transactions or a standard workload to group entities owned by a specific team. The newrelic_workload resource within the official terraform-provider-newrelic repository now supports both workload types.

Prerequisites

Before you begin:

  • Install the Terraform CLI on your machine.
  • Initialize a local working directory for your Terraform project.
  • Obtain a valid New Relic User API key (NerdGraph API access) and your account ID.
  • Export your credentials as environment variables (NEW_RELIC_API_KEY, NEW_RELIC_ACCOUNT_ID, and NEW_RELIC_REGION) rather than hardcoding them in your configuration files to keep your credentials secure.
  • Install terraform-provider-newrelic v3.94.0 or later. This is the minimum version required for Intelligent Workload support (dynamic_flows, status_config_alert_policy).

Importante

Do not use a License or Ingest key. Provisioning workload resources requires user-level API permissions.

Set up authentication

Declare the New Relic provider in your primary Terraform configuration file:

terraform {
required_providers {
newrelic = {
source = "newrelic/newrelic"
version = ">= 3.94.0"
}
}
}
provider "newrelic" {
# Configuration inherits NEW_RELIC_API_KEY, NEW_RELIC_ACCOUNT_ID, and NEW_RELIC_REGION from environment variables
}

Create standard workloads

Define the newrelic_workload resource using search queries, explicit entity GUID lists, or account scope boundaries. Use this approach when you want to manually group specific infrastructure, applications, or services owned by a team.

resource "newrelic_workload" "team_standard_workload" {
name = "Payments Team Workload"
account_id = 1234567 # Replace with your New Relic Account ID
# Group entities using a search query
entity_search_query {
query = "name LIKE 'payment-%' AND type = 'SERVICE'"
}
}

Create intelligent workloads

Use the dynamic_flows configuration block. The main benefit of intelligent workloads is that once you designate an entry point entity GUID and transaction name in the dynamic_flows block, New Relic automatically discovers and maps upstream and downstream entity dependencies via distributed tracing (Transaction 360), refreshing them every 5 minutes. This means you don't need to manually update GUIDs or re-apply Terraform configurations when your underlying service architecture changes.

Sugerencia

To find your entry point entity GUID, navigate to the entity in the New Relic UI and copy the GUID from the entity's metadata, or retrieve it using the NerdGraph entities API.

Intelligent workloads can also derive their health status from alert conditions: Set status_config_alert_policy { enabled = true } on the workload, then attach newrelic_nrql_alert_condition resources by setting their target_entity to the workload's guid.

resource "newrelic_workload" "checkout_intelligent_workload" {
name = "Checkout Transaction Flow"
account_id = 1234567 # Replace with your New Relic Account ID
dynamic_flows {
entity_guid = "Mzg3fEFQTX..." # Replace with your entry point entity GUID
transaction_name = "WebTransaction/Action/checkout"
}
status_config_alert_policy {
enabled = true
}
}

Apply your configuration

After you define the resource block, run the following commands from your terminal:

bash
$
terraform init
$
terraform plan
$
terraform apply

After Terraform successfully provisions the workload, navigate to one.newrelic.com > All capabilities > Workloads> to verify the new resource. You can inspect the automatically discovered entities in the transaction flow, review the alert policy bindings, and verify that the status rollups reflect the correct workload health.

Copyright © 2026 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.