import * as pulumi from "@pulumi/pulumi"; /** * Use this resource to create and manage New Relic Workflow Automation. * * Workflow Automation allows you to define automated workflows using YAML definitions. These workflows can scope to either an account or an organization and support various automation steps and configurations. * * ## Example Usage * * ### Basic Workflow Automation with ACCOUNT Scope * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as newrelic from "@pulumi/newrelic"; * * const testQuery = new newrelic.WorkflowAutomation("test_query", { * name: "test_query_workflow", * scopeId: "your-account-id", * scopeType: "ACCOUNT", * definition: `name: test_query_workflow * description: Simple workflow that queries NRDB and waits * steps: * - name: queryNrdb * type: action * action: newrelic.nrdb.query * version: 1 * inputs: * query: SELECT count(*) from Log LIMIT 10 * - name: wait * type: wait * seconds: 3 * signals: [] * next: end * `, * }); * ``` * * ### Workflow Automation with ORGANIZATION Scope * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as newrelic from "@pulumi/newrelic"; * * const orgQuery = new newrelic.WorkflowAutomation("org_query", { * name: "org_query_workflow", * scopeId: "your-organization-id", * scopeType: "ORGANIZATION", * definition: `name: org_query_workflow * description: Organization-level workflow that queries NRDB * steps: * - name: queryNrdb * type: action * action: newrelic.nrdb.query * version: 1 * inputs: * query: SELECT count(*) from Transaction LIMIT 10 * - name: wait * type: wait * seconds: 5 * signals: [] * next: end * `, * }); * ``` * * ## [YAML Definition Structure](https://docs.newrelic.com/docs/workflow-automation/workflow-automation-apis/definition-schema/) * * The `definition` argument accepts a YAML string that defines the workflow's structure and logic. * * ### Top-Level Fields * * | Field | Type | Required | Description | * | ----- | ----- | ----- | ----- | * | `name` | String | Yes | The name of the workflow. Must match the `name` argument in the Terraform resource. | * | `description` | String | No | A brief summary of what the workflow does. Recommended for clarity. | * | `workflowInputs` | Object | No | A map of input variables that can be passed to the workflow at runtime. | * | `steps` | Array | Yes | An ordered array of step objects that define the workflow's logic. | * * *** * * ### Workflow Inputs * * Define inputs to make your workflows more flexible and reusable. * * * Inputs can reference secrets using the syntax: `${{ :secrets:secretName }}` * * #### Input Validation Types * * Workflow inputs support various validation types to ensure data integrity: * * * [Regex Validation:](https://docs.newrelic.com/docs/workflow-automation/workflow-automation-apis/definition-schema/#validation-types) * * * Integer Range Validation: * * **Note**: By default, integer variables accept both positive and negative values. If you define a *minIntValue* validation, the field rejects any value below that threshold. For example, setting *minIntValue: 0* prevents negative integers from being entered. * * * List Type: * * **Note**: This list is case sensitive. * * **Step Types** * * Each object in the `steps` array defines a single unit of work. The primary step types are [`action`, `wait`, `switch`, and `loop`.](https://docs.newrelic.com/docs/workflow-automation/create-a-workflow-automation/create-your-own/#core-concepts) * * #### Action Steps * * Executes a specific function, such as querying data or sending a notification. * * * `type: action` \- Defines the step as an action. * * `action` \- The specific action to execute (example, `newrelic.nrdb.query`). * * `version` \- The version of the action to use. * * `inputs` \- A map of input parameters for the action. * * Example: * * **Common actions include:** * * * `newrelic.nrdb.query` \- Query New Relic database * * `utils.transform.toCSV` \- Transform data to CSV format * * `slack.chat.postMessage` \- Send messages to Slack * * **Available actions** * A complete list of available actions, their versions, and required inputs can be found in the [**Workflow Action Catalog**](https://docs.newrelic.com/docs/workflow-automation/actions-catalog/). * * #### Wait steps * * Pauses the workflow for a specified duration or until it receives a signal. * * * `type: wait` * * `seconds` \- The number of seconds to pause. * * `signals` \- (Optional) An array of signals to wait for. See [SignalWorkflowRun](https://docs.newrelic.com/docs/workflow-automation/workflow-automation-apis/signal-workflow-run/) for more information * * `next` \- (Optional) The name of the next step. Use `end` to terminate the workflow. * * Example: * * #### Switch steps * * Provides conditional branching logic. * * * `type: switch` * * `switch` \- An array of conditions to evaluate in order. * * `condition` \- A JQ expression that evaluates to `true` or `false`. * * `next` \- The name of the step to execute if the condition is true. The `switch` block can also have a top-level `next` field to define the default step if no conditions match. * * Example: * * #### Loop steps * * Iterates over a set of values and executes a sequence of steps for each iteration. * * * `type: loop` * * `for.in` \- A JQ expression that returns an array to iterate over. * * `steps` \- An array of steps to execute for each iteration. Inside the loop, you can use `next: continue` to skip to the next iteration or `next: break` to exit the loop. * * Example: * * *** * * ### Referencing Data in Workflows * * You can dynamically reference data from inputs, secrets, and other steps using JQ-like template expressions. * * | Data Source | Syntax | Example | * | ----- | ----- | ----- | * | **Workflow Inputs** | `${{ .workflowInputs.inputName }}` | `${{ .workflowInputs.ccuThreshold }}` | * | **Step Outputs** | `${{ .steps.stepName.outputs.fieldName }}` | `${{ .steps.query1.outputs.results }}` | * | **Loop Elements** | `${{ .steps.loopStepName.loop.element }}` | `${{ .steps.loopStep1.loop.element.email }}` | * | **Secrets** | `${{ :secrets:secretName }}` | `${{ :secrets:myApiKey }}` | * * *** * * ### Example YAML Structure * * Simple workflow with query and wait: * * Advanced workflow with inputs and multiple actions: * * ## Important note * * ### Name Consistency * * The `name` field in the Terraform resource must match the name field in the YAML definition. If they don't match, Terraform will return an error during `terraform validate`, `plan`, or `apply`. * * Example Error Message: * * For example, this configuration is **correct**: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as newrelic from "@pulumi/newrelic"; * * const example = new newrelic.WorkflowAutomation("example", { * name: "my-workflow", * scopeId: "1234567", * scopeType: "ACCOUNT", * definition: `name: my-workflow # This matches the resource name * description: Example workflow * steps: * - name: waitStep * type: wait * seconds: 10 * `, * }); * ``` * * This configuration is **incorrect** and will fail: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as newrelic from "@pulumi/newrelic"; * * const example = new newrelic.WorkflowAutomation("example", { * name: "my-workflow", * scopeId: "1234567", * scopeType: "ACCOUNT", * definition: `name: different-name # This doesn't match the resource name - ERROR! * description: Example workflow * steps: * - name: waitStep * type: wait * seconds: 10 * `, * }); * ``` * * ### Scope type * * * **ACCOUNT** \- The workflow automation is scoped to a specific New Relic account. Use your numeric account ID as the `scopeId`. * * **ORGANIZATION** \- The workflow automation is scoped to your entire New Relic organization. Use your organization ID string as the `scopeId`. * * See, [Create accounts and organizations](https://docs.newrelic.com/docs/accounts/accounts-billing/account-structure/multi-tenancy/org-creation/) on how to create an account or an organization. * * ### ForceNew attributes * * The following attributes, when changed, will force creation of a new resource : * * * `name` \- Changing the workflow name creates a new resource. * * `scopeId` \- Changing the scope ID creates a new resource. * * `scopeType` \- Changing between **ACCOUNT** and **ORGANIZATION** creates a new resource. * * ### YAML validation * * The provider validates the YAML definition during plan-and-apply operations: * * * The YAML must be valid and parsable. * * The `name` field must be present in the YAML. * * The `name` in the YAML must match the Terraform resource name. * * Invalid YAML or missing required fields will result in an error. * * Example YAML validation errors: * * YAML Validation Error * 1. *waitStep* has invalid type "waitAgain". Valid types are: * action, loop, switch, wait, assign * * 2. Workflow definition names can not be changed. * * ### *Versioning* * * Each time you update the `definition` of a workflow automation, New Relic automatically increments the `version` attribute. This allows you to track changes to your workflow automation over time. * * ## Import * * Import workflow automations using the composite ID format: `##`, for example: * * ```sh * $ pulumi import newrelic:index/workflowAutomation:WorkflowAutomation test_query ACCOUNT#1234567#test_query_workflow * ``` * * ```sh * $ pulumi import newrelic:index/workflowAutomation:WorkflowAutomation ccu_governance ACCOUNT#1234567#CCUGovernance * ``` * * For organization-scoped workflows: * * ```sh * $ pulumi import newrelic:index/workflowAutomation:WorkflowAutomation org_query ORGANIZATION#org-id#org_query_workflow * ``` */ export declare class WorkflowAutomation extends pulumi.CustomResource { /** * Get an existing WorkflowAutomation resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: WorkflowAutomationState, opts?: pulumi.CustomResourceOptions): WorkflowAutomation; /** * Returns true if the given object is an instance of WorkflowAutomation. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is WorkflowAutomation; /** * \- (Required) The YAML definition of the workflow. This must be a valid YAML string that defines the workflow's configuration. */ readonly definition: pulumi.Output; /** * The ID of the workflow automation. */ readonly definitionId: pulumi.Output; /** * \- The description of the workflow, as defined in the YAML. */ readonly description: pulumi.Output; /** * \- (Required) The name of the workflow. This must match the `name` field in the YAML `definition`. **Important**: Changing this field will force a new resource to be created. */ readonly name: pulumi.Output; /** * \- (Required) The ID of the scope for the workflow. For `ACCOUNT` scope, this is your New Relic account ID (numeric). For `ORGANIZATION` scope, this is your organization ID (string). **Important**: Changing this field will force a new resource to be created. */ readonly scopeId: pulumi.Output; /** * \- (Required) The scope type for the workflow. Must be either `ACCOUNT` or `ORGANIZATION`. **Important**: Changing this field will force a new resource to be created. */ readonly scopeType: pulumi.Output; /** * \- The current version number of the workflow. This number increments with each update to the `definition`. */ readonly version: pulumi.Output; /** * The yaml of the workflow automation. */ readonly yaml: pulumi.Output; /** * Create a WorkflowAutomation resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: WorkflowAutomationArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering WorkflowAutomation resources. */ export interface WorkflowAutomationState { /** * \- (Required) The YAML definition of the workflow. This must be a valid YAML string that defines the workflow's configuration. */ definition?: pulumi.Input; /** * The ID of the workflow automation. */ definitionId?: pulumi.Input; /** * \- The description of the workflow, as defined in the YAML. */ description?: pulumi.Input; /** * \- (Required) The name of the workflow. This must match the `name` field in the YAML `definition`. **Important**: Changing this field will force a new resource to be created. */ name?: pulumi.Input; /** * \- (Required) The ID of the scope for the workflow. For `ACCOUNT` scope, this is your New Relic account ID (numeric). For `ORGANIZATION` scope, this is your organization ID (string). **Important**: Changing this field will force a new resource to be created. */ scopeId?: pulumi.Input; /** * \- (Required) The scope type for the workflow. Must be either `ACCOUNT` or `ORGANIZATION`. **Important**: Changing this field will force a new resource to be created. */ scopeType?: pulumi.Input; /** * \- The current version number of the workflow. This number increments with each update to the `definition`. */ version?: pulumi.Input; /** * The yaml of the workflow automation. */ yaml?: pulumi.Input; } /** * The set of arguments for constructing a WorkflowAutomation resource. */ export interface WorkflowAutomationArgs { /** * \- (Required) The YAML definition of the workflow. This must be a valid YAML string that defines the workflow's configuration. */ definition: pulumi.Input; /** * \- (Required) The name of the workflow. This must match the `name` field in the YAML `definition`. **Important**: Changing this field will force a new resource to be created. */ name?: pulumi.Input; /** * \- (Required) The ID of the scope for the workflow. For `ACCOUNT` scope, this is your New Relic account ID (numeric). For `ORGANIZATION` scope, this is your organization ID (string). **Important**: Changing this field will force a new resource to be created. */ scopeId: pulumi.Input; /** * \- (Required) The scope type for the workflow. Must be either `ACCOUNT` or `ORGANIZATION`. **Important**: Changing this field will force a new resource to be created. */ scopeType: pulumi.Input; } //# sourceMappingURL=workflowAutomation.d.ts.map