New Relic v5.45.0 published on Friday, Apr 18, 2025 by Pulumi
newrelic.getObfuscationExpression
Explore with Pulumi AI
Use this data source to get information about a specific Obfuscation Expression in New Relic that already exists.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as newrelic from "@pulumi/newrelic";
const expression = newrelic.getObfuscationExpression({
    accountId: "123456",
    name: "The expression",
});
const rule = new newrelic.ObfuscationRule("rule", {
    name: "ruleName",
    description: "description of the rule",
    filter: "hostStatus=running",
    enabled: true,
    actions: [{
        attributes: ["message"],
        expressionId: expression.then(expression => expression.id),
        method: "MASK",
    }],
});
import pulumi
import pulumi_newrelic as newrelic
expression = newrelic.get_obfuscation_expression(account_id="123456",
    name="The expression")
rule = newrelic.ObfuscationRule("rule",
    name="ruleName",
    description="description of the rule",
    filter="hostStatus=running",
    enabled=True,
    actions=[{
        "attributes": ["message"],
        "expression_id": expression.id,
        "method": "MASK",
    }])
package main
import (
	"github.com/pulumi/pulumi-newrelic/sdk/v5/go/newrelic"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		expression, err := newrelic.LookupObfuscationExpression(ctx, &newrelic.LookupObfuscationExpressionArgs{
			AccountId: pulumi.StringRef("123456"),
			Name:      "The expression",
		}, nil)
		if err != nil {
			return err
		}
		_, err = newrelic.NewObfuscationRule(ctx, "rule", &newrelic.ObfuscationRuleArgs{
			Name:        pulumi.String("ruleName"),
			Description: pulumi.String("description of the rule"),
			Filter:      pulumi.String("hostStatus=running"),
			Enabled:     pulumi.Bool(true),
			Actions: newrelic.ObfuscationRuleActionArray{
				&newrelic.ObfuscationRuleActionArgs{
					Attributes: pulumi.StringArray{
						pulumi.String("message"),
					},
					ExpressionId: pulumi.String(expression.Id),
					Method:       pulumi.String("MASK"),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using NewRelic = Pulumi.NewRelic;
return await Deployment.RunAsync(() => 
{
    var expression = NewRelic.GetObfuscationExpression.Invoke(new()
    {
        AccountId = "123456",
        Name = "The expression",
    });
    var rule = new NewRelic.ObfuscationRule("rule", new()
    {
        Name = "ruleName",
        Description = "description of the rule",
        Filter = "hostStatus=running",
        Enabled = true,
        Actions = new[]
        {
            new NewRelic.Inputs.ObfuscationRuleActionArgs
            {
                Attributes = new[]
                {
                    "message",
                },
                ExpressionId = expression.Apply(getObfuscationExpressionResult => getObfuscationExpressionResult.Id),
                Method = "MASK",
            },
        },
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.newrelic.NewrelicFunctions;
import com.pulumi.newrelic.inputs.GetObfuscationExpressionArgs;
import com.pulumi.newrelic.ObfuscationRule;
import com.pulumi.newrelic.ObfuscationRuleArgs;
import com.pulumi.newrelic.inputs.ObfuscationRuleActionArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        final var expression = NewrelicFunctions.getObfuscationExpression(GetObfuscationExpressionArgs.builder()
            .accountId("123456")
            .name("The expression")
            .build());
        var rule = new ObfuscationRule("rule", ObfuscationRuleArgs.builder()
            .name("ruleName")
            .description("description of the rule")
            .filter("hostStatus=running")
            .enabled(true)
            .actions(ObfuscationRuleActionArgs.builder()
                .attributes("message")
                .expressionId(expression.id())
                .method("MASK")
                .build())
            .build());
    }
}
resources:
  rule:
    type: newrelic:ObfuscationRule
    properties:
      name: ruleName
      description: description of the rule
      filter: hostStatus=running
      enabled: true # Reference the obfuscation expression data source in the obfuscation rule resource
      actions:
        - attributes:
            - message
          expressionId: ${expression.id}
          method: MASK
variables:
  expression:
    fn::invoke:
      function: newrelic:getObfuscationExpression
      arguments:
        accountId: 123456
        name: The expression
Using getObfuscationExpression
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getObfuscationExpression(args: GetObfuscationExpressionArgs, opts?: InvokeOptions): Promise<GetObfuscationExpressionResult>
function getObfuscationExpressionOutput(args: GetObfuscationExpressionOutputArgs, opts?: InvokeOptions): Output<GetObfuscationExpressionResult>def get_obfuscation_expression(account_id: Optional[str] = None,
                               name: Optional[str] = None,
                               opts: Optional[InvokeOptions] = None) -> GetObfuscationExpressionResult
def get_obfuscation_expression_output(account_id: Optional[pulumi.Input[str]] = None,
                               name: Optional[pulumi.Input[str]] = None,
                               opts: Optional[InvokeOptions] = None) -> Output[GetObfuscationExpressionResult]func LookupObfuscationExpression(ctx *Context, args *LookupObfuscationExpressionArgs, opts ...InvokeOption) (*LookupObfuscationExpressionResult, error)
func LookupObfuscationExpressionOutput(ctx *Context, args *LookupObfuscationExpressionOutputArgs, opts ...InvokeOption) LookupObfuscationExpressionResultOutput> Note: This function is named LookupObfuscationExpression in the Go SDK.
public static class GetObfuscationExpression 
{
    public static Task<GetObfuscationExpressionResult> InvokeAsync(GetObfuscationExpressionArgs args, InvokeOptions? opts = null)
    public static Output<GetObfuscationExpressionResult> Invoke(GetObfuscationExpressionInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetObfuscationExpressionResult> getObfuscationExpression(GetObfuscationExpressionArgs args, InvokeOptions options)
public static Output<GetObfuscationExpressionResult> getObfuscationExpression(GetObfuscationExpressionArgs args, InvokeOptions options)
fn::invoke:
  function: newrelic:index/getObfuscationExpression:getObfuscationExpression
  arguments:
    # arguments dictionaryThe following arguments are supported:
- name str
 - Name of expression.
 - account_
id str - The account id associated with the obfuscation expression. If left empty will default to account ID specified in provider level configuration.
 
getObfuscationExpression Result
The following output properties are available:
- id str
 - The provider-assigned unique ID for this managed resource.
 - name str
 - account_
id str 
Package Details
- Repository
 - New Relic pulumi/pulumi-newrelic
 - License
 - Apache-2.0
 - Notes
 - This Pulumi package is based on the 
newrelicTerraform Provider.