Table of Contents

Class NotificationRule

Namespace
Amazon.CDK.AWS.CodeStarNotifications
Assembly
Amazon.CDK.AWS.CodeStarNotifications.dll

A new notification rule.

public class NotificationRule : Resource, INotificationRule, IResource, IConstruct, IConstruct, IDependable
Inheritance
NotificationRule
Implements
IResource
IConstruct
IConstruct
IDependable

Examples

using Amazon.CDK.AWS.CodeStarNotifications;
             using Amazon.CDK.AWS.CodeBuild;
             using Amazon.CDK.AWS.SNS;
             using Amazon.CDK.AWS.Chatbot;


             var project = new PipelineProject(this, "MyProject");

             var topic = new Topic(this, "MyTopic1");

             var slack = new SlackChannelConfiguration(this, "MySlackChannel", new SlackChannelConfigurationProps {
                 SlackChannelConfigurationName = "YOUR_CHANNEL_NAME",
                 SlackWorkspaceId = "YOUR_SLACK_WORKSPACE_ID",
                 SlackChannelId = "YOUR_SLACK_CHANNEL_ID"
             });

             var rule = new NotificationRule(this, "NotificationRule", new NotificationRuleProps {
                 Source = project,
                 Events = new [] { "codebuild-project-build-state-succeeded", "codebuild-project-build-state-failed" },
                 Targets = new [] { topic }
             });
             rule.AddTarget(slack);

Remarks

Resource: AWS::CodeStarNotifications::NotificationRule

ExampleMetadata: infused

Constructors

NotificationRule(Construct, string, INotificationRuleProps)

public NotificationRule(Construct scope, string id, INotificationRuleProps props)

Parameters

scope Construct
id string
props INotificationRuleProps

Properties

NotificationRuleArn

The ARN of the notification rule (i.e. arn:aws:codestar-notifications:::notificationrule/01234abcde).

public virtual string NotificationRuleArn { get; }

Property Value

string

Remarks

Attribute: true

Methods

AddTarget(INotificationRuleTarget)

Adds target to notification rule.

public virtual bool AddTarget(INotificationRuleTarget target)

Parameters

target INotificationRuleTarget

The SNS topic or AWS Chatbot Slack target.

Returns

bool

FromNotificationRuleArn(Construct, string, string)

Import an existing notification rule provided an ARN.

public static INotificationRule FromNotificationRuleArn(Construct scope, string id, string notificationRuleArn)

Parameters

scope Construct

The parent creating construct.

id string

The construct's name.

notificationRuleArn string

Notification rule ARN (i.e. arn:aws:codestar-notifications:::notificationrule/01234abcde).

Returns

INotificationRule