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

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()
    {
        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 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.IntRef(123456),
			Name:      "The expression",
		}, nil)
		if err != nil {
			return err
		}
		_, err = newrelic.NewObfuscationRule(ctx, "rule", &newrelic.ObfuscationRuleArgs{
			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
	})
}
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()        
            .description("description of the rule")
            .filter("hostStatus=running")
            .enabled(true)
            .actions(ObfuscationRuleActionArgs.builder()
                .attributes("message")
                .expressionId(expression.applyValue(getObfuscationExpressionResult -> getObfuscationExpressionResult.id()))
                .method("MASK")
                .build())
            .build());

    }
}
import pulumi
import pulumi_newrelic as newrelic

expression = newrelic.get_obfuscation_expression(account_id=123456,
    name="The expression")
rule = newrelic.ObfuscationRule("rule",
    description="description of the rule",
    filter="hostStatus=running",
    enabled=True,
    actions=[newrelic.ObfuscationRuleActionArgs(
        attributes=["message"],
        expression_id=expression.id,
        method="MASK",
    )])
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", {
    description: "description of the rule",
    filter: "hostStatus=running",
    enabled: true,
    actions: [{
        attributes: ["message"],
        expressionId: expression.then(expression => expression.id),
        method: "MASK",
    }],
});
resources:
  rule:
    type: newrelic:ObfuscationRule
    properties:
      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[int] = None,
                               name: Optional[str] = None,
                               opts: Optional[InvokeOptions] = None) -> GetObfuscationExpressionResult
def get_obfuscation_expression_output(account_id: Optional[pulumi.Input[int]] = 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)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: newrelic:index/getObfuscationExpression:getObfuscationExpression
  arguments:
    # arguments dictionary

The following arguments are supported:

Name string

Name of expression.

AccountId int

The account id associated with the obfuscation expression. If left empty will default to account ID specified in provider level configuration.

Name string

Name of expression.

AccountId int

The account id associated with the obfuscation expression. If left empty will default to account ID specified in provider level configuration.

name String

Name of expression.

accountId Integer

The account id associated with the obfuscation expression. If left empty will default to account ID specified in provider level configuration.

name string

Name of expression.

accountId number

The account id associated with the obfuscation expression. If left empty will default to account ID specified in provider level configuration.

name str

Name of expression.

account_id int

The account id associated with the obfuscation expression. If left empty will default to account ID specified in provider level configuration.

name String

Name of expression.

accountId Number

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 string

The provider-assigned unique ID for this managed resource.

Name string
AccountId int
Id string

The provider-assigned unique ID for this managed resource.

Name string
AccountId int
id String

The provider-assigned unique ID for this managed resource.

name String
accountId Integer
id string

The provider-assigned unique ID for this managed resource.

name string
accountId number
id str

The provider-assigned unique ID for this managed resource.

name str
account_id int
id String

The provider-assigned unique ID for this managed resource.

name String
accountId Number

Package Details

Repository
New Relic pulumi/pulumi-newrelic
License
Apache-2.0
Notes

This Pulumi package is based on the newrelic Terraform Provider.