Registry /
aws / aws-cdk-aws-codestarnotifications
Install & Compatibility
Where this runs
tested against v1.204.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 38MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 4.2s · import 0.000s · 38MB
38MB installed
● package 38MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
NotificationRule
✓ from aws_cdk import aws_codestarnotifications as notifications
DetailType
✓ from aws_cdk import aws_codestarnotifications as notifications
This quickstart demonstrates how to create an AWS CodeStar Notification Rule using AWS CDK v1. It sets up a CodeCommit repository as the notification source and an SNS topic as the target. Notifications are configured for specific CodeCommit events. This code is designed to be part of a larger CDK application.
import os
from aws_cdk import (
aws_codecommit as codecommit,
aws_sns as sns,
aws_codestarnotifications as notifications,
core as cdk
)
class CodeStarNotificationsExampleStack(cdk.Stack):
def __init__(self, scope: cdk.App, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
# Create a CodeCommit repository as the source for notifications
repo = codecommit.Repository(self, "MyCodeCommitRepo",
repository_name="my-app-repository-for-notifications"
)
# Create an SNS topic as the target for notifications
# In a real scenario, you'd likely subscribe an email or Lambda to this topic.
notification_topic = sns.Topic(self, "MyNotificationTopic")
# Create a Notification Rule
# This rule will send notifications to the SNS topic for specific CodeCommit events.
notifications.NotificationRule(self, "RepoNotificationRule",
source=repo,
events=[
"codecommit-repository-comments-on-commits",
"codecommit-repository-pull-request-created",
"codecommit-repository-pull-request-merged"
],
targets=[notification_topic],
detail_type=notifications.DetailType.FULL # Or DetailType.BASIC
)
# Example of how to synthesize this stack (usually in app.py)
# app = cdk.App()
# CodeStarNotificationsExampleStack(app, "CodeStarNotificationsExampleStack")
# app.synth()
cdk --version
Debug
Known issues
breakingAWS CDK v1 (`aws-cdk.aws-*`) is fundamentally different from AWS CDK v2 (`aws-cdk-lib`). Imports, module structure, and even some construct names have changed. This entry focuses on v1.204.0.fixFor new projects, prefer `aws-cdk-lib`. To migrate v1 to v2, consult the official CDK migration guide. For this library, in v2, constructs are found under `from aws_cdk import aws_codestarnotifications as notifications`.
affects: All v1.x vs v2.x
deprecatedAWS CDK v1 is in maintenance mode. Active development, new features, and most bug fixes are focused on AWS CDK v2. Users are strongly encouraged to migrate to v2.fixPlan and execute a migration to AWS CDK v2 for new and existing projects to benefit from ongoing support and new features.
affects: All v1.x
gotchaMixing different minor versions of `aws-cdk.core` and `aws-cdk.aws-codestarnotifications` (or other `aws-cdk.aws-*` packages) can lead to runtime errors or unexpected behavior. All CDK v1 packages used in a project should typically be at the same version.fixEnsure all `aws-cdk.core` and `aws-cdk.aws-*` packages explicitly installed in your project (e.g., in `requirements.txt`) are pinned to the exact same version, for example, `==1.204.0`.
affects: All v1.x
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'aws_cdk.aws_codestarnotifications'
The package `aws-cdk-aws-codestarnotifications` is not installed, or `aws-cdk.core` is not installed, or Python environment path issues.
fixEnsure the package is installed: `pip install aws-cdk-aws-codestarnotifications==1.204.0`. Also, ensure `aws-cdk.core` of the matching version is installed: `pip install aws-cdk.core==1.204.0`.
TypeError: Argument 'source' must be an instance of <class 'aws_cdk.aws_codecommit.Repository'>
This usually happens when `source` is an object from a different CDK version (e.g., v2 `aws_cdk_lib.aws_codecommit.Repository`) or a different type entirely, incompatible with the v1 `NotificationRule` expecting a v1 `Repository`.
fixVerify that all related CDK constructs (source, target, and the notification rule itself) are from the same CDK major version (v1 in this case). Ensure all `aws-cdk.aws-*` packages are consistently installed at the same v1.x.x version.
AttributeError: module 'aws_cdk.aws_codestarnotifications' has no attribute 'NotificationRule'
This error often indicates an attempt to use a v2 import pattern or construct name with a v1 installation, or a typo in the construct name.
fixDouble-check your import statement and construct name. For CDK v1, the correct import for this module is `from aws_cdk import aws_codestarnotifications as notifications` and the class is `notifications.NotificationRule`. Ensure `aws-cdk-aws-codestarnotifications` is installed and matches your `aws-cdk.core` version.
Upgrade
Version history
1.204.0latest on PyPI · released Jun 19, 2023
Audit
Dependencies
aws-cdk.corerequiredRequired for all CDK v1 applications; must match the exact version of the construct library.
aws-cdk.aws-codecommitoptionalCommonly used as a source for CodeStar Notifications.
aws-cdk.aws-snsoptionalCommonly used as a target for CodeStar Notifications.