NotificationRuleProps

class aws_cdk.aws_codestarnotifications.NotificationRuleProps(*, detail_type=None, enabled=None, notification_rule_name=None, events, source, targets=None)

Bases: NotificationRuleOptions

Properties for a new notification rule.

Parameters:
  • detail_type (Optional[DetailType]) – The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created. Default: DetailType.FULL

  • enabled (Optional[bool]) – The status of the notification rule. If the enabled is set to DISABLED, notifications aren’t sent for the notification rule. Default: true

  • notification_rule_name (Optional[str]) – The name for the notification rule. Notification rule names must be unique in your AWS account. Default: - generated from the id

  • events (Sequence[str]) – A list of event types associated with this notification rule. For a complete list of event types and IDs, see Notification concepts in the Developer Tools Console User Guide.

  • source (INotificationRuleSource) – The Amazon Resource Name (ARN) of the resource to associate with the notification rule. Currently, Supported sources include pipelines in AWS CodePipeline, build projects in AWS CodeBuild, and repositories in AWS CodeCommit in this L2 constructor.

  • targets (Optional[Sequence[INotificationRuleTarget]]) – The targets to register for the notification destination. Default: - No targets are added to the rule. Use addTarget() to add a target.

ExampleMetadata:

infused

Example:

import aws_cdk.aws_codestarnotifications as notifications
import aws_cdk.aws_codebuild as codebuild
import aws_cdk.aws_sns as sns
import aws_cdk.aws_chatbot as chatbot


project = codebuild.PipelineProject(self, "MyProject")

topic = sns.Topic(self, "MyTopic1")

slack = chatbot.SlackChannelConfiguration(self, "MySlackChannel",
    slack_channel_configuration_name="YOUR_CHANNEL_NAME",
    slack_workspace_id="YOUR_SLACK_WORKSPACE_ID",
    slack_channel_id="YOUR_SLACK_CHANNEL_ID"
)

rule = notifications.NotificationRule(self, "NotificationRule",
    source=project,
    events=["codebuild-project-build-state-succeeded", "codebuild-project-build-state-failed"
    ],
    targets=[topic]
)
rule.add_target(slack)

Attributes

detail_type

The level of detail to include in the notifications for this resource.

BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created.

Default:

DetailType.FULL

enabled

The status of the notification rule.

If the enabled is set to DISABLED, notifications aren’t sent for the notification rule.

Default:

true

events

A list of event types associated with this notification rule.

For a complete list of event types and IDs, see Notification concepts in the Developer Tools Console User Guide.

See:

https://docs.aws.amazon.com/dtconsole/latest/userguide/concepts.html#concepts-api

notification_rule_name

The name for the notification rule.

Notification rule names must be unique in your AWS account.

Default:
  • generated from the id

source

The Amazon Resource Name (ARN) of the resource to associate with the notification rule.

Currently, Supported sources include pipelines in AWS CodePipeline, build projects in AWS CodeBuild, and repositories in AWS CodeCommit in this L2 constructor.

See:

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codestarnotifications-notificationrule.html#cfn-codestarnotifications-notificationrule-resource

targets

The targets to register for the notification destination.

Default:
  • No targets are added to the rule. Use addTarget() to add a target.