AlertPolicyChannel

Use this resource to map alert policies to alert channels in New Relic.

Example Usage

using Pulumi;
using NewRelic = Pulumi.NewRelic;

class MyStack : Stack
{
    public MyStack()
    {
        var examplePolicy = Output.Create(NewRelic.GetAlertPolicy.InvokeAsync(new NewRelic.GetAlertPolicyArgs
        {
            Name = "my-alert-policy",
        }));
        // Creates an email alert channel.
        var emailChannel = new NewRelic.AlertChannel("emailChannel", new NewRelic.AlertChannelArgs
        {
            Type = "email",
            Config = new NewRelic.Inputs.AlertChannelConfigArgs
            {
                Recipients = "foo@example.com",
                IncludeJsonAttachment = "1",
            },
        });
        // Creates a Slack alert channel.
        var slackChannel = new NewRelic.AlertChannel("slackChannel", new NewRelic.AlertChannelArgs
        {
            Type = "slack",
            Config = new NewRelic.Inputs.AlertChannelConfigArgs
            {
                Channel = "#example-channel",
                Url = "http://example-org.slack.com",
            },
        });
        // Applies the created channels above to the alert policy
        // referenced at the top of the config.
        var foo = new NewRelic.AlertPolicyChannel("foo", new NewRelic.AlertPolicyChannelArgs
        {
            PolicyId = newrelic_alert_policy.Example_policy.Id,
            ChannelIds = 
            {
                emailChannel.Id,
                slackChannel.Id,
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-newrelic/sdk/v4/go/newrelic"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := newrelic.LookupAlertPolicy(ctx, &newrelic.LookupAlertPolicyArgs{
			Name: "my-alert-policy",
		}, nil)
		if err != nil {
			return err
		}
		emailChannel, err := newrelic.NewAlertChannel(ctx, "emailChannel", &newrelic.AlertChannelArgs{
			Type: pulumi.String("email"),
			Config: &newrelic.AlertChannelConfigArgs{
				Recipients:            pulumi.String("foo@example.com"),
				IncludeJsonAttachment: pulumi.String("1"),
			},
		})
		if err != nil {
			return err
		}
		slackChannel, err := newrelic.NewAlertChannel(ctx, "slackChannel", &newrelic.AlertChannelArgs{
			Type: pulumi.String("slack"),
			Config: &newrelic.AlertChannelConfigArgs{
				Channel: pulumi.String("#example-channel"),
				Url:     pulumi.String("http://example-org.slack.com"),
			},
		})
		if err != nil {
			return err
		}
		_, err = newrelic.NewAlertPolicyChannel(ctx, "foo", &newrelic.AlertPolicyChannelArgs{
			PolicyId: pulumi.Any(newrelic_alert_policy.Example_policy.Id),
			ChannelIds: pulumi.IntArray{
				emailChannel.ID(),
				slackChannel.ID(),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_newrelic as newrelic

example_policy = newrelic.get_alert_policy(name="my-alert-policy")
# Creates an email alert channel.
email_channel = newrelic.AlertChannel("emailChannel",
    type="email",
    config=newrelic.AlertChannelConfigArgs(
        recipients="foo@example.com",
        include_json_attachment="1",
    ))
# Creates a Slack alert channel.
slack_channel = newrelic.AlertChannel("slackChannel",
    type="slack",
    config=newrelic.AlertChannelConfigArgs(
        channel="#example-channel",
        url="http://example-org.slack.com",
    ))
# Applies the created channels above to the alert policy
# referenced at the top of the config.
foo = newrelic.AlertPolicyChannel("foo",
    policy_id=newrelic_alert_policy["example_policy"]["id"],
    channel_ids=[
        email_channel.id,
        slack_channel.id,
    ])
import * as pulumi from "@pulumi/pulumi";
import * as newrelic from "@pulumi/newrelic";

const examplePolicy = newrelic.getAlertPolicy({
    name: "my-alert-policy",
});
// Creates an email alert channel.
const emailChannel = new newrelic.AlertChannel("emailChannel", {
    type: "email",
    config: {
        recipients: "foo@example.com",
        includeJsonAttachment: "1",
    },
});
// Creates a Slack alert channel.
const slackChannel = new newrelic.AlertChannel("slackChannel", {
    type: "slack",
    config: {
        channel: "#example-channel",
        url: "http://example-org.slack.com",
    },
});
// Applies the created channels above to the alert policy
// referenced at the top of the config.
const foo = new newrelic.AlertPolicyChannel("foo", {
    policyId: newrelic_alert_policy.example_policy.id,
    channelIds: [
        emailChannel.id,
        slackChannel.id,
    ],
});

Create a AlertPolicyChannel Resource

new AlertPolicyChannel(name: string, args: AlertPolicyChannelArgs, opts?: CustomResourceOptions);
@overload
def AlertPolicyChannel(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       channel_ids: Optional[Sequence[int]] = None,
                       policy_id: Optional[int] = None)
@overload
def AlertPolicyChannel(resource_name: str,
                       args: AlertPolicyChannelArgs,
                       opts: Optional[ResourceOptions] = None)
func NewAlertPolicyChannel(ctx *Context, name string, args AlertPolicyChannelArgs, opts ...ResourceOption) (*AlertPolicyChannel, error)
public AlertPolicyChannel(string name, AlertPolicyChannelArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args AlertPolicyChannelArgs
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 AlertPolicyChannelArgs
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 AlertPolicyChannelArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args AlertPolicyChannelArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

AlertPolicyChannel Resource Properties

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

Inputs

The AlertPolicyChannel resource accepts the following input properties:

ChannelIds List<int>
Array of channel IDs to apply to the specified policy. We recommended sorting channel IDs in ascending order to avoid drift in your state.
PolicyId int
The ID of the policy.
ChannelIds []int
Array of channel IDs to apply to the specified policy. We recommended sorting channel IDs in ascending order to avoid drift in your state.
PolicyId int
The ID of the policy.
channelIds number[]
Array of channel IDs to apply to the specified policy. We recommended sorting channel IDs in ascending order to avoid drift in your state.
policyId number
The ID of the policy.
channel_ids Sequence[int]
Array of channel IDs to apply to the specified policy. We recommended sorting channel IDs in ascending order to avoid drift in your state.
policy_id int
The ID of the policy.

Outputs

All input properties are implicitly available as output properties. Additionally, the AlertPolicyChannel 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 str
The provider-assigned unique ID for this managed resource.

Look up an Existing AlertPolicyChannel Resource

Get an existing AlertPolicyChannel 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?: AlertPolicyChannelState, opts?: CustomResourceOptions): AlertPolicyChannel
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        channel_ids: Optional[Sequence[int]] = None,
        policy_id: Optional[int] = None) -> AlertPolicyChannel
func GetAlertPolicyChannel(ctx *Context, name string, id IDInput, state *AlertPolicyChannelState, opts ...ResourceOption) (*AlertPolicyChannel, error)
public static AlertPolicyChannel Get(string name, Input<string> id, AlertPolicyChannelState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

ChannelIds List<int>
Array of channel IDs to apply to the specified policy. We recommended sorting channel IDs in ascending order to avoid drift in your state.
PolicyId int
The ID of the policy.
ChannelIds []int
Array of channel IDs to apply to the specified policy. We recommended sorting channel IDs in ascending order to avoid drift in your state.
PolicyId int
The ID of the policy.
channelIds number[]
Array of channel IDs to apply to the specified policy. We recommended sorting channel IDs in ascending order to avoid drift in your state.
policyId number
The ID of the policy.
channel_ids Sequence[int]
Array of channel IDs to apply to the specified policy. We recommended sorting channel IDs in ascending order to avoid drift in your state.
policy_id int
The ID of the policy.

Import

Alert policy channels can be imported using the following notation<policyID>:<channelID>:<channelID>, e.g.

 $ pulumi import newrelic:index/alertPolicyChannel:AlertPolicyChannel foo 123456:3462754:2938324

When importing newrelic_alert_policy_channel resource, the attribute channel_ids* will be set in your Terraform state. You can import multiple channels as long as those channel IDs are included as part of the import ID hash.

Package Details

Repository
https://github.com/pulumi/pulumi-newrelic
License
Apache-2.0
Notes
This Pulumi package is based on the newrelic Terraform Provider.