1. Packages
  2. New Relic
  3. API Docs
  4. AlertPolicy
New Relic v5.36.1 published on Tuesday, Nov 12, 2024 by Pulumi

newrelic.AlertPolicy

Explore with Pulumi AI

newrelic logo
New Relic v5.36.1 published on Tuesday, Nov 12, 2024 by Pulumi

    Use this resource to create and manage New Relic alert policies.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as newrelic from "@pulumi/newrelic";
    
    const foo = new newrelic.AlertPolicy("foo", {
        name: "example",
        incidentPreference: "PER_POLICY",
    });
    
    import pulumi
    import pulumi_newrelic as newrelic
    
    foo = newrelic.AlertPolicy("foo",
        name="example",
        incident_preference="PER_POLICY")
    
    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 {
    		_, err := newrelic.NewAlertPolicy(ctx, "foo", &newrelic.AlertPolicyArgs{
    			Name:               pulumi.String("example"),
    			IncidentPreference: pulumi.String("PER_POLICY"),
    		})
    		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 foo = new NewRelic.AlertPolicy("foo", new()
        {
            Name = "example",
            IncidentPreference = "PER_POLICY",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.newrelic.AlertPolicy;
    import com.pulumi.newrelic.AlertPolicyArgs;
    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) {
            var foo = new AlertPolicy("foo", AlertPolicyArgs.builder()
                .name("example")
                .incidentPreference("PER_POLICY")
                .build());
    
        }
    }
    
    resources:
      foo:
        type: newrelic:AlertPolicy
        properties:
          name: example
          incidentPreference: PER_POLICY
    

    Provision multiple notification channels and add those channels to a policy

    The following arguments are supported:

    • name - (Required) The name of the policy.
    • incident_preference - (Optional) The rollup strategy for the policy, which can have one of the following values (the default value is PER_POLICY):
      • PER_POLICY - This sets the incident grouping preference of the policy to One issue per policy. Refer to this page for more details on this incident grouping preference.
      • PER_CONDITION - This sets the incident grouping preference of the policy to One issue per condition. Refer to this page for more details on this incident grouping preference.
      • PER_CONDITION_AND_TARGET - This sets the incident grouping preference of the policy to One issue per condition and signal. Refer to this page for more details on this incident grouping preference.
    • channel_ids - (Optional) DEPRECATED The channel_ids argument is deprecated and will be removed in the next major release of the provider. An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed. Also note that channel IDs cannot be imported via pulumi import (see Import for info).
    • account_id - (Optional) The New Relic account ID to operate on. This allows the user to override the account_id attribute set on the provider. Defaults to the environment variable NEW_RELIC_ACCOUNT_ID.

    Additional Examples

    Provision multiple notification channels and add those channels to a policy
    import * as pulumi from "@pulumi/pulumi";
    import * as newrelic from "@pulumi/newrelic";
    
    // Provision a Slack notification channel.
    const slackChannel = new newrelic.AlertChannel("slack_channel", {
        name: "slack-example",
        type: "slack",
        config: {
            url: "https://hooks.slack.com/services/xxxxxxx/yyyyyyyy",
            channel: "example-alerts-channel",
        },
    });
    // Provision an email notification channel.
    const emailChannel = new newrelic.AlertChannel("email_channel", {
        name: "email-example",
        type: "email",
        config: {
            recipients: "example@testing.com",
            includeJsonAttachment: "1",
        },
    });
    // Provision the alert policy.
    const policyWithChannels = new newrelic.AlertPolicy("policy_with_channels", {
        name: "example-with-channels",
        incidentPreference: "PER_CONDITION",
        channelIds: [
            slackChannel.id,
            emailChannel.id,
        ],
    });
    
    import pulumi
    import pulumi_newrelic as newrelic
    
    # Provision a Slack notification channel.
    slack_channel = newrelic.AlertChannel("slack_channel",
        name="slack-example",
        type="slack",
        config={
            "url": "https://hooks.slack.com/services/xxxxxxx/yyyyyyyy",
            "channel": "example-alerts-channel",
        })
    # Provision an email notification channel.
    email_channel = newrelic.AlertChannel("email_channel",
        name="email-example",
        type="email",
        config={
            "recipients": "example@testing.com",
            "include_json_attachment": "1",
        })
    # Provision the alert policy.
    policy_with_channels = newrelic.AlertPolicy("policy_with_channels",
        name="example-with-channels",
        incident_preference="PER_CONDITION",
        channel_ids=[
            slack_channel.id,
            email_channel.id,
        ])
    
    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 {
    		// Provision a Slack notification channel.
    		slackChannel, err := newrelic.NewAlertChannel(ctx, "slack_channel", &newrelic.AlertChannelArgs{
    			Name: pulumi.String("slack-example"),
    			Type: pulumi.String("slack"),
    			Config: &newrelic.AlertChannelConfigArgs{
    				Url:     pulumi.String("https://hooks.slack.com/services/xxxxxxx/yyyyyyyy"),
    				Channel: pulumi.String("example-alerts-channel"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// Provision an email notification channel.
    		emailChannel, err := newrelic.NewAlertChannel(ctx, "email_channel", &newrelic.AlertChannelArgs{
    			Name: pulumi.String("email-example"),
    			Type: pulumi.String("email"),
    			Config: &newrelic.AlertChannelConfigArgs{
    				Recipients:            pulumi.String("example@testing.com"),
    				IncludeJsonAttachment: pulumi.String("1"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// Provision the alert policy.
    		_, err = newrelic.NewAlertPolicy(ctx, "policy_with_channels", &newrelic.AlertPolicyArgs{
    			Name:               pulumi.String("example-with-channels"),
    			IncidentPreference: pulumi.String("PER_CONDITION"),
    			ChannelIds: pulumi.StringArray{
    				slackChannel.ID(),
    				emailChannel.ID(),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using NewRelic = Pulumi.NewRelic;
    
    return await Deployment.RunAsync(() => 
    {
        // Provision a Slack notification channel.
        var slackChannel = new NewRelic.AlertChannel("slack_channel", new()
        {
            Name = "slack-example",
            Type = "slack",
            Config = new NewRelic.Inputs.AlertChannelConfigArgs
            {
                Url = "https://hooks.slack.com/services/xxxxxxx/yyyyyyyy",
                Channel = "example-alerts-channel",
            },
        });
    
        // Provision an email notification channel.
        var emailChannel = new NewRelic.AlertChannel("email_channel", new()
        {
            Name = "email-example",
            Type = "email",
            Config = new NewRelic.Inputs.AlertChannelConfigArgs
            {
                Recipients = "example@testing.com",
                IncludeJsonAttachment = "1",
            },
        });
    
        // Provision the alert policy.
        var policyWithChannels = new NewRelic.AlertPolicy("policy_with_channels", new()
        {
            Name = "example-with-channels",
            IncidentPreference = "PER_CONDITION",
            ChannelIds = new[]
            {
                slackChannel.Id,
                emailChannel.Id,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.newrelic.AlertChannel;
    import com.pulumi.newrelic.AlertChannelArgs;
    import com.pulumi.newrelic.inputs.AlertChannelConfigArgs;
    import com.pulumi.newrelic.AlertPolicy;
    import com.pulumi.newrelic.AlertPolicyArgs;
    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) {
            // Provision a Slack notification channel.
            var slackChannel = new AlertChannel("slackChannel", AlertChannelArgs.builder()
                .name("slack-example")
                .type("slack")
                .config(AlertChannelConfigArgs.builder()
                    .url("https://hooks.slack.com/services/xxxxxxx/yyyyyyyy")
                    .channel("example-alerts-channel")
                    .build())
                .build());
    
            // Provision an email notification channel.
            var emailChannel = new AlertChannel("emailChannel", AlertChannelArgs.builder()
                .name("email-example")
                .type("email")
                .config(AlertChannelConfigArgs.builder()
                    .recipients("example@testing.com")
                    .includeJsonAttachment("1")
                    .build())
                .build());
    
            // Provision the alert policy.
            var policyWithChannels = new AlertPolicy("policyWithChannels", AlertPolicyArgs.builder()
                .name("example-with-channels")
                .incidentPreference("PER_CONDITION")
                .channelIds(            
                    slackChannel.id(),
                    emailChannel.id())
                .build());
    
        }
    }
    
    resources:
      # Provision a Slack notification channel.
      slackChannel:
        type: newrelic:AlertChannel
        name: slack_channel
        properties:
          name: slack-example
          type: slack
          config:
            url: https://hooks.slack.com/services/xxxxxxx/yyyyyyyy
            channel: example-alerts-channel
      # Provision an email notification channel.
      emailChannel:
        type: newrelic:AlertChannel
        name: email_channel
        properties:
          name: email-example
          type: email
          config:
            recipients: example@testing.com
            includeJsonAttachment: '1'
      # Provision the alert policy.
      policyWithChannels:
        type: newrelic:AlertPolicy
        name: policy_with_channels
        properties:
          name: example-with-channels
          incidentPreference: PER_CONDITION
          channelIds:
            - ${slackChannel.id}
            - ${emailChannel.id}
    

    Reference existing notification channels and add those channel to a policy

    import * as pulumi from "@pulumi/pulumi";
    import * as newrelic from "@pulumi/newrelic";
    
    // Reference an existing Slack notification channel.
    const slackChannel = newrelic.getAlertChannel({
        name: "slack-channel-notification",
    });
    // Reference an existing email notification channel.
    const emailChannel = newrelic.getAlertChannel({
        name: "test@example.com",
    });
    // Provision the alert policy.
    const policyWithChannels = new newrelic.AlertPolicy("policy_with_channels", {
        name: "example-with-channels",
        incidentPreference: "PER_CONDITION",
        channelIds: [
            slackChannel.then(slackChannel => slackChannel.id),
            emailChannel.then(emailChannel => emailChannel.id),
        ],
    });
    
    import pulumi
    import pulumi_newrelic as newrelic
    
    # Reference an existing Slack notification channel.
    slack_channel = newrelic.get_alert_channel(name="slack-channel-notification")
    # Reference an existing email notification channel.
    email_channel = newrelic.get_alert_channel(name="test@example.com")
    # Provision the alert policy.
    policy_with_channels = newrelic.AlertPolicy("policy_with_channels",
        name="example-with-channels",
        incident_preference="PER_CONDITION",
        channel_ids=[
            slack_channel.id,
            email_channel.id,
        ])
    
    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 {
    		// Reference an existing Slack notification channel.
    		slackChannel, err := newrelic.LookupAlertChannel(ctx, &newrelic.LookupAlertChannelArgs{
    			Name: "slack-channel-notification",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		// Reference an existing email notification channel.
    		emailChannel, err := newrelic.LookupAlertChannel(ctx, &newrelic.LookupAlertChannelArgs{
    			Name: "test@example.com",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		// Provision the alert policy.
    		_, err = newrelic.NewAlertPolicy(ctx, "policy_with_channels", &newrelic.AlertPolicyArgs{
    			Name:               pulumi.String("example-with-channels"),
    			IncidentPreference: pulumi.String("PER_CONDITION"),
    			ChannelIds: pulumi.StringArray{
    				pulumi.String(slackChannel.Id),
    				pulumi.String(emailChannel.Id),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using NewRelic = Pulumi.NewRelic;
    
    return await Deployment.RunAsync(() => 
    {
        // Reference an existing Slack notification channel.
        var slackChannel = NewRelic.GetAlertChannel.Invoke(new()
        {
            Name = "slack-channel-notification",
        });
    
        // Reference an existing email notification channel.
        var emailChannel = NewRelic.GetAlertChannel.Invoke(new()
        {
            Name = "test@example.com",
        });
    
        // Provision the alert policy.
        var policyWithChannels = new NewRelic.AlertPolicy("policy_with_channels", new()
        {
            Name = "example-with-channels",
            IncidentPreference = "PER_CONDITION",
            ChannelIds = new[]
            {
                slackChannel.Apply(getAlertChannelResult => getAlertChannelResult.Id),
                emailChannel.Apply(getAlertChannelResult => getAlertChannelResult.Id),
            },
        });
    
    });
    
    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.GetAlertChannelArgs;
    import com.pulumi.newrelic.AlertPolicy;
    import com.pulumi.newrelic.AlertPolicyArgs;
    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) {
            // Reference an existing Slack notification channel.
            final var slackChannel = NewrelicFunctions.getAlertChannel(GetAlertChannelArgs.builder()
                .name("slack-channel-notification")
                .build());
    
            // Reference an existing email notification channel.
            final var emailChannel = NewrelicFunctions.getAlertChannel(GetAlertChannelArgs.builder()
                .name("test@example.com")
                .build());
    
            // Provision the alert policy.
            var policyWithChannels = new AlertPolicy("policyWithChannels", AlertPolicyArgs.builder()
                .name("example-with-channels")
                .incidentPreference("PER_CONDITION")
                .channelIds(            
                    slackChannel.applyValue(getAlertChannelResult -> getAlertChannelResult.id()),
                    emailChannel.applyValue(getAlertChannelResult -> getAlertChannelResult.id()))
                .build());
    
        }
    }
    
    resources:
      # Provision the alert policy.
      policyWithChannels:
        type: newrelic:AlertPolicy
        name: policy_with_channels
        properties:
          name: example-with-channels
          incidentPreference: PER_CONDITION
          channelIds:
            - ${slackChannel.id}
            - ${emailChannel.id}
    variables:
      # Reference an existing Slack notification channel.
      slackChannel:
        fn::invoke:
          Function: newrelic:getAlertChannel
          Arguments:
            name: slack-channel-notification
      # Reference an existing email notification channel.
      emailChannel:
        fn::invoke:
          Function: newrelic:getAlertChannel
          Arguments:
            name: test@example.com
    

    Create AlertPolicy Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new AlertPolicy(name: string, args?: AlertPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def AlertPolicy(resource_name: str,
                    args: Optional[AlertPolicyArgs] = None,
                    opts: Optional[ResourceOptions] = None)
    
    @overload
    def AlertPolicy(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    account_id: Optional[str] = None,
                    channel_ids: Optional[Sequence[str]] = None,
                    incident_preference: Optional[str] = None,
                    name: Optional[str] = None)
    func NewAlertPolicy(ctx *Context, name string, args *AlertPolicyArgs, opts ...ResourceOption) (*AlertPolicy, error)
    public AlertPolicy(string name, AlertPolicyArgs? args = null, CustomResourceOptions? opts = null)
    public AlertPolicy(String name, AlertPolicyArgs args)
    public AlertPolicy(String name, AlertPolicyArgs args, CustomResourceOptions options)
    
    type: newrelic:AlertPolicy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args AlertPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args AlertPolicyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args AlertPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args AlertPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args AlertPolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var alertPolicyResource = new NewRelic.AlertPolicy("alertPolicyResource", new()
    {
        AccountId = "string",
        IncidentPreference = "string",
        Name = "string",
    });
    
    example, err := newrelic.NewAlertPolicy(ctx, "alertPolicyResource", &newrelic.AlertPolicyArgs{
    	AccountId:          pulumi.String("string"),
    	IncidentPreference: pulumi.String("string"),
    	Name:               pulumi.String("string"),
    })
    
    var alertPolicyResource = new AlertPolicy("alertPolicyResource", AlertPolicyArgs.builder()
        .accountId("string")
        .incidentPreference("string")
        .name("string")
        .build());
    
    alert_policy_resource = newrelic.AlertPolicy("alertPolicyResource",
        account_id="string",
        incident_preference="string",
        name="string")
    
    const alertPolicyResource = new newrelic.AlertPolicy("alertPolicyResource", {
        accountId: "string",
        incidentPreference: "string",
        name: "string",
    });
    
    type: newrelic:AlertPolicy
    properties:
        accountId: string
        incidentPreference: string
        name: string
    

    AlertPolicy Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The AlertPolicy resource accepts the following input properties:

    AccountId string
    The New Relic account ID to operate on. This allows the user to override the account_id attribute set on the provider. Defaults to the environment variable NEW_RELIC_ACCOUNT_ID.
    ChannelIds List<string>
    An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed. Also note that channel IDs cannot be imported.

    Deprecated: The channel_ids attribute is deprecated and will be removed in the next major release of the provider.

    IncidentPreference string
    The rollup strategy for the policy. Options include: PER_POLICY, PER_CONDITION, or PER_CONDITION_AND_TARGET. The default is PER_POLICY.
    Name string
    The name of the policy.
    AccountId string
    The New Relic account ID to operate on. This allows the user to override the account_id attribute set on the provider. Defaults to the environment variable NEW_RELIC_ACCOUNT_ID.
    ChannelIds []string
    An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed. Also note that channel IDs cannot be imported.

    Deprecated: The channel_ids attribute is deprecated and will be removed in the next major release of the provider.

    IncidentPreference string
    The rollup strategy for the policy. Options include: PER_POLICY, PER_CONDITION, or PER_CONDITION_AND_TARGET. The default is PER_POLICY.
    Name string
    The name of the policy.
    accountId String
    The New Relic account ID to operate on. This allows the user to override the account_id attribute set on the provider. Defaults to the environment variable NEW_RELIC_ACCOUNT_ID.
    channelIds List<String>
    An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed. Also note that channel IDs cannot be imported.

    Deprecated: The channel_ids attribute is deprecated and will be removed in the next major release of the provider.

    incidentPreference String
    The rollup strategy for the policy. Options include: PER_POLICY, PER_CONDITION, or PER_CONDITION_AND_TARGET. The default is PER_POLICY.
    name String
    The name of the policy.
    accountId string
    The New Relic account ID to operate on. This allows the user to override the account_id attribute set on the provider. Defaults to the environment variable NEW_RELIC_ACCOUNT_ID.
    channelIds string[]
    An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed. Also note that channel IDs cannot be imported.

    Deprecated: The channel_ids attribute is deprecated and will be removed in the next major release of the provider.

    incidentPreference string
    The rollup strategy for the policy. Options include: PER_POLICY, PER_CONDITION, or PER_CONDITION_AND_TARGET. The default is PER_POLICY.
    name string
    The name of the policy.
    account_id str
    The New Relic account ID to operate on. This allows the user to override the account_id attribute set on the provider. Defaults to the environment variable NEW_RELIC_ACCOUNT_ID.
    channel_ids Sequence[str]
    An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed. Also note that channel IDs cannot be imported.

    Deprecated: The channel_ids attribute is deprecated and will be removed in the next major release of the provider.

    incident_preference str
    The rollup strategy for the policy. Options include: PER_POLICY, PER_CONDITION, or PER_CONDITION_AND_TARGET. The default is PER_POLICY.
    name str
    The name of the policy.
    accountId String
    The New Relic account ID to operate on. This allows the user to override the account_id attribute set on the provider. Defaults to the environment variable NEW_RELIC_ACCOUNT_ID.
    channelIds List<String>
    An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed. Also note that channel IDs cannot be imported.

    Deprecated: The channel_ids attribute is deprecated and will be removed in the next major release of the provider.

    incidentPreference String
    The rollup strategy for the policy. Options include: PER_POLICY, PER_CONDITION, or PER_CONDITION_AND_TARGET. The default is PER_POLICY.
    name String
    The name of the policy.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the AlertPolicy resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing AlertPolicy Resource

    Get an existing AlertPolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: AlertPolicyState, opts?: CustomResourceOptions): AlertPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            account_id: Optional[str] = None,
            channel_ids: Optional[Sequence[str]] = None,
            incident_preference: Optional[str] = None,
            name: Optional[str] = None) -> AlertPolicy
    func GetAlertPolicy(ctx *Context, name string, id IDInput, state *AlertPolicyState, opts ...ResourceOption) (*AlertPolicy, error)
    public static AlertPolicy Get(string name, Input<string> id, AlertPolicyState? state, CustomResourceOptions? opts = null)
    public static AlertPolicy get(String name, Output<String> id, AlertPolicyState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    AccountId string
    The New Relic account ID to operate on. This allows the user to override the account_id attribute set on the provider. Defaults to the environment variable NEW_RELIC_ACCOUNT_ID.
    ChannelIds List<string>
    An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed. Also note that channel IDs cannot be imported.

    Deprecated: The channel_ids attribute is deprecated and will be removed in the next major release of the provider.

    IncidentPreference string
    The rollup strategy for the policy. Options include: PER_POLICY, PER_CONDITION, or PER_CONDITION_AND_TARGET. The default is PER_POLICY.
    Name string
    The name of the policy.
    AccountId string
    The New Relic account ID to operate on. This allows the user to override the account_id attribute set on the provider. Defaults to the environment variable NEW_RELIC_ACCOUNT_ID.
    ChannelIds []string
    An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed. Also note that channel IDs cannot be imported.

    Deprecated: The channel_ids attribute is deprecated and will be removed in the next major release of the provider.

    IncidentPreference string
    The rollup strategy for the policy. Options include: PER_POLICY, PER_CONDITION, or PER_CONDITION_AND_TARGET. The default is PER_POLICY.
    Name string
    The name of the policy.
    accountId String
    The New Relic account ID to operate on. This allows the user to override the account_id attribute set on the provider. Defaults to the environment variable NEW_RELIC_ACCOUNT_ID.
    channelIds List<String>
    An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed. Also note that channel IDs cannot be imported.

    Deprecated: The channel_ids attribute is deprecated and will be removed in the next major release of the provider.

    incidentPreference String
    The rollup strategy for the policy. Options include: PER_POLICY, PER_CONDITION, or PER_CONDITION_AND_TARGET. The default is PER_POLICY.
    name String
    The name of the policy.
    accountId string
    The New Relic account ID to operate on. This allows the user to override the account_id attribute set on the provider. Defaults to the environment variable NEW_RELIC_ACCOUNT_ID.
    channelIds string[]
    An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed. Also note that channel IDs cannot be imported.

    Deprecated: The channel_ids attribute is deprecated and will be removed in the next major release of the provider.

    incidentPreference string
    The rollup strategy for the policy. Options include: PER_POLICY, PER_CONDITION, or PER_CONDITION_AND_TARGET. The default is PER_POLICY.
    name string
    The name of the policy.
    account_id str
    The New Relic account ID to operate on. This allows the user to override the account_id attribute set on the provider. Defaults to the environment variable NEW_RELIC_ACCOUNT_ID.
    channel_ids Sequence[str]
    An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed. Also note that channel IDs cannot be imported.

    Deprecated: The channel_ids attribute is deprecated and will be removed in the next major release of the provider.

    incident_preference str
    The rollup strategy for the policy. Options include: PER_POLICY, PER_CONDITION, or PER_CONDITION_AND_TARGET. The default is PER_POLICY.
    name str
    The name of the policy.
    accountId String
    The New Relic account ID to operate on. This allows the user to override the account_id attribute set on the provider. Defaults to the environment variable NEW_RELIC_ACCOUNT_ID.
    channelIds List<String>
    An array of channel IDs (integers) to assign to the policy. Adding or removing channel IDs from this array will result in a new alert policy resource being created and the old one being destroyed. Also note that channel IDs cannot be imported.

    Deprecated: The channel_ids attribute is deprecated and will be removed in the next major release of the provider.

    incidentPreference String
    The rollup strategy for the policy. Options include: PER_POLICY, PER_CONDITION, or PER_CONDITION_AND_TARGET. The default is PER_POLICY.
    name String
    The name of the policy.

    Import

    Alert policies can be imported using a composite ID of <id>:<account_id>, where account_id is the account number scoped to the alert policy resource.

    Example import:

    $ pulumi import newrelic:index/alertPolicy:AlertPolicy foo 23423556:4593020
    

    Please note that channel IDs (channel_ids) cannot be imported due channels being a separate resource. However, to add channels to an imported alert policy, you can import the policy, add the channel_ids attribute with the associated channel IDs, then run pulumi up. This will result in the original alert policy being destroyed and a new alert policy being created along with the channels being added to the policy.

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    New Relic pulumi/pulumi-newrelic
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the newrelic Terraform Provider.
    newrelic logo
    New Relic v5.36.1 published on Tuesday, Nov 12, 2024 by Pulumi