NotificationRule

Provides a CodeStar Notifications Rule.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var code = new Aws.CodeCommit.Repository("code", new Aws.CodeCommit.RepositoryArgs
        {
            RepositoryName = "example-code-repo",
        });
        var notif = new Aws.Sns.Topic("notif", new Aws.Sns.TopicArgs
        {
        });
        var notifAccess = notif.Arn.Apply(arn => Aws.Iam.GetPolicyDocument.InvokeAsync(new Aws.Iam.GetPolicyDocumentArgs
        {
            Statements = 
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementArgs
                {
                    Actions = 
                    {
                        "sns:Publish",
                    },
                    Principals = 
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalArgs
                        {
                            Type = "Service",
                            Identifiers = 
                            {
                                "codestar-notifications.amazonaws.com",
                            },
                        },
                    },
                    Resources = 
                    {
                        arn,
                    },
                },
            },
        }));
        var @default = new Aws.Sns.TopicPolicy("default", new Aws.Sns.TopicPolicyArgs
        {
            Arn = notif.Arn,
            Policy = notifAccess.Apply(notifAccess => notifAccess.Json),
        });
        var commits = new Aws.CodeStarNotifications.NotificationRule("commits", new Aws.CodeStarNotifications.NotificationRuleArgs
        {
            DetailType = "BASIC",
            EventTypeIds = 
            {
                "codecommit-repository-comments-on-commits",
            },
            Resource = code.Arn,
            Targets = 
            {
                new Aws.CodeStarNotifications.Inputs.NotificationRuleTargetArgs
                {
                    Address = notif.Arn,
                },
            },
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/codecommit"
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/codestarnotifications"
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/iam"
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/sns"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        code, err := codecommit.NewRepository(ctx, "code", &codecommit.RepositoryArgs{
            RepositoryName: pulumi.String("example-code-repo"),
        })
        if err != nil {
            return err
        }
        notif, err := sns.NewTopic(ctx, "notif", nil)
        if err != nil {
            return err
        }
        _, err = sns.NewTopicPolicy(ctx, "_default", &sns.TopicPolicyArgs{
            Arn: notif.Arn,
            Policy: notifAccess.ApplyT(func(notifAccess iam.GetPolicyDocumentResult) (string, error) {
                return notifAccess.Json, nil
            }).(pulumi.StringOutput),
        })
        if err != nil {
            return err
        }
        _, err = codestarnotifications.NewNotificationRule(ctx, "commits", &codestarnotifications.NotificationRuleArgs{
            DetailType: pulumi.String("BASIC"),
            EventTypeIds: pulumi.StringArray{
                pulumi.String("codecommit-repository-comments-on-commits"),
            },
            Resource: code.Arn,
            Targets: codestarnotifications.NotificationRuleTargetArray{
                &codestarnotifications.NotificationRuleTargetArgs{
                    Address: notif.Arn,
                },
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

code = aws.codecommit.Repository("code", repository_name="example-code-repo")
notif = aws.sns.Topic("notif")
notif_access = notif.arn.apply(lambda arn: aws.iam.get_policy_document(statements=[{
    "actions": ["sns:Publish"],
    "principals": [{
        "type": "Service",
        "identifiers": ["codestar-notifications.amazonaws.com"],
    }],
    "resources": [arn],
}]))
default = aws.sns.TopicPolicy("default",
    arn=notif.arn,
    policy=notif_access.json)
commits = aws.codestarnotifications.NotificationRule("commits",
    detail_type="BASIC",
    event_type_ids=["codecommit-repository-comments-on-commits"],
    resource=code.arn,
    targets=[{
        "address": notif.arn,
    }])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const code = new aws.codecommit.Repository("code", {repositoryName: "example-code-repo"});
const notif = new aws.sns.Topic("notif", {});
const notifAccess = notif.arn.apply(arn => aws.iam.getPolicyDocument({
    statements: [{
        actions: ["sns:Publish"],
        principals: [{
            type: "Service",
            identifiers: ["codestar-notifications.amazonaws.com"],
        }],
        resources: [arn],
    }],
}));
const _default = new aws.sns.TopicPolicy("default", {
    arn: notif.arn,
    policy: notifAccess.json,
});
const commits = new aws.codestarnotifications.NotificationRule("commits", {
    detailType: "BASIC",
    eventTypeIds: ["codecommit-repository-comments-on-commits"],
    resource: code.arn,
    targets: [{
        address: notif.arn,
    }],
});

Create a NotificationRule Resource

def NotificationRule(resource_name, opts=None, detail_type=None, event_type_ids=None, name=None, resource=None, status=None, tags=None, targets=None, __props__=None);
name string
The unique name of the resource.
args NotificationRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args NotificationRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args NotificationRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

NotificationRule Resource Properties

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

Inputs

The NotificationRule resource accepts the following input properties:

DetailType string

The level of detail to include in the notifications for this resource. Possible values are BASIC and FULL.

EventTypeIds List<string>

A list of event types associated with this notification rule. For list of allowed events see here.

Resource string

The ARN of the resource to associate with the notification rule.

Name string

The name of notification rule.

Status string

The status of the notification rule. Possible values are ENABLED and DISABLED, default is ENABLED.

Tags Dictionary<string, string>

A map of tags to assign to the resource.

Targets List<NotificationRuleTargetArgs>

Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.

DetailType string

The level of detail to include in the notifications for this resource. Possible values are BASIC and FULL.

EventTypeIds []string

A list of event types associated with this notification rule. For list of allowed events see here.

Resource string

The ARN of the resource to associate with the notification rule.

Name string

The name of notification rule.

Status string

The status of the notification rule. Possible values are ENABLED and DISABLED, default is ENABLED.

Tags map[string]string

A map of tags to assign to the resource.

Targets []NotificationRuleTarget

Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.

detailType string

The level of detail to include in the notifications for this resource. Possible values are BASIC and FULL.

eventTypeIds string[]

A list of event types associated with this notification rule. For list of allowed events see here.

resource string

The ARN of the resource to associate with the notification rule.

name string

The name of notification rule.

status string

The status of the notification rule. Possible values are ENABLED and DISABLED, default is ENABLED.

tags {[key: string]: string}

A map of tags to assign to the resource.

targets NotificationRuleTarget[]

Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.

detail_type str

The level of detail to include in the notifications for this resource. Possible values are BASIC and FULL.

event_type_ids List[str]

A list of event types associated with this notification rule. For list of allowed events see here.

resource str

The ARN of the resource to associate with the notification rule.

name str

The name of notification rule.

status str

The status of the notification rule. Possible values are ENABLED and DISABLED, default is ENABLED.

tags Dict[str, str]

A map of tags to assign to the resource.

targets List[NotificationRuleTarget]

Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.

Outputs

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

Arn string

The codestar notification rule ARN.

Id string
The provider-assigned unique ID for this managed resource.
Arn string

The codestar notification rule ARN.

Id string
The provider-assigned unique ID for this managed resource.
arn string

The codestar notification rule ARN.

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

The codestar notification rule ARN.

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

Look up an Existing NotificationRule Resource

Get an existing NotificationRule 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?: NotificationRuleState, opts?: CustomResourceOptions): NotificationRule
static get(resource_name, id, opts=None, arn=None, detail_type=None, event_type_ids=None, name=None, resource=None, status=None, tags=None, targets=None, __props__=None);
func GetNotificationRule(ctx *Context, name string, id IDInput, state *NotificationRuleState, opts ...ResourceOption) (*NotificationRule, error)
public static NotificationRule Get(string name, Input<string> id, NotificationRuleState? 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:

Arn string

The codestar notification rule ARN.

DetailType string

The level of detail to include in the notifications for this resource. Possible values are BASIC and FULL.

EventTypeIds List<string>

A list of event types associated with this notification rule. For list of allowed events see here.

Name string

The name of notification rule.

Resource string

The ARN of the resource to associate with the notification rule.

Status string

The status of the notification rule. Possible values are ENABLED and DISABLED, default is ENABLED.

Tags Dictionary<string, string>

A map of tags to assign to the resource.

Targets List<NotificationRuleTargetArgs>

Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.

Arn string

The codestar notification rule ARN.

DetailType string

The level of detail to include in the notifications for this resource. Possible values are BASIC and FULL.

EventTypeIds []string

A list of event types associated with this notification rule. For list of allowed events see here.

Name string

The name of notification rule.

Resource string

The ARN of the resource to associate with the notification rule.

Status string

The status of the notification rule. Possible values are ENABLED and DISABLED, default is ENABLED.

Tags map[string]string

A map of tags to assign to the resource.

Targets []NotificationRuleTarget

Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.

arn string

The codestar notification rule ARN.

detailType string

The level of detail to include in the notifications for this resource. Possible values are BASIC and FULL.

eventTypeIds string[]

A list of event types associated with this notification rule. For list of allowed events see here.

name string

The name of notification rule.

resource string

The ARN of the resource to associate with the notification rule.

status string

The status of the notification rule. Possible values are ENABLED and DISABLED, default is ENABLED.

tags {[key: string]: string}

A map of tags to assign to the resource.

targets NotificationRuleTarget[]

Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.

arn str

The codestar notification rule ARN.

detail_type str

The level of detail to include in the notifications for this resource. Possible values are BASIC and FULL.

event_type_ids List[str]

A list of event types associated with this notification rule. For list of allowed events see here.

name str

The name of notification rule.

resource str

The ARN of the resource to associate with the notification rule.

status str

The status of the notification rule. Possible values are ENABLED and DISABLED, default is ENABLED.

tags Dict[str, str]

A map of tags to assign to the resource.

targets List[NotificationRuleTarget]

Configuration blocks containing notification target information. Can be specified multiple times. At least one target must be specified on creation.

Supporting Types

NotificationRuleTarget

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Address string

The ARN of notification rule target. For example, a SNS Topic ARN.

Status string

The status of the notification rule. Possible values are ENABLED and DISABLED, default is ENABLED.

Type string

The type of the notification target. Default value is SNS.

Address string

The ARN of notification rule target. For example, a SNS Topic ARN.

Status string

The status of the notification rule. Possible values are ENABLED and DISABLED, default is ENABLED.

Type string

The type of the notification target. Default value is SNS.

address string

The ARN of notification rule target. For example, a SNS Topic ARN.

status string

The status of the notification rule. Possible values are ENABLED and DISABLED, default is ENABLED.

type string

The type of the notification target. Default value is SNS.

address str

The ARN of notification rule target. For example, a SNS Topic ARN.

status str

The status of the notification rule. Possible values are ENABLED and DISABLED, default is ENABLED.

type str

The type of the notification target. Default value is SNS.

Package Details

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