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
-
IResourceIConstructIConstructIDependable
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
Constructid
stringprops
INotificationRuleProps
Properties
NotificationRuleArn
The ARN of the notification rule (i.e. arn:aws:codestar-notifications:::notificationrule/01234abcde).
public virtual string NotificationRuleArn { get; }
Property Value
Remarks
Attribute: true
Methods
AddTarget(INotificationRuleTarget)
Adds target to notification rule.
public virtual bool AddTarget(INotificationRuleTarget target)
Parameters
target
INotificationRuleTargetThe SNS topic or AWS Chatbot Slack target.
Returns
FromNotificationRuleArn(Construct, string, string)
Import an existing notification rule provided an ARN.
public static INotificationRule FromNotificationRuleArn(Construct scope, string id, string notificationRuleArn)
Parameters
scope
ConstructThe parent creating construct.
id
stringThe construct's name.
notificationRuleArn
stringNotification rule ARN (i.e. arn:aws:codestar-notifications:::notificationrule/01234abcde).