{"id":9513,"library":"aws-cdk-aws-codestarnotifications","title":"AWS CDK CodeStarNotifications (v1)","description":"The `aws-cdk-aws-codestarnotifications` package is part of the AWS Cloud Development Kit (CDK) v1, providing constructs for managing AWS CodeStar Notifications. These constructs allow you to create rules to send notifications about events from various AWS services (like CodeCommit, CodeBuild, CodePipeline) to targets such as Amazon SNS topics or AWS Chatbot. As of version `1.204.0`, AWS CDK v1 is in maintenance mode, with active development focused on CDK v2. New projects are encouraged to use CDK v2.","status":"maintenance","version":"1.204.0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-cdk.git","tags":["aws","cdk","codestarnotifications","infrastructure-as-code","iac","aws-cdk-v1"],"install":[{"cmd":"pip install aws-cdk-aws-codestarnotifications==1.204.0","lang":"bash","label":"Install specific version"},{"cmd":"pip install aws-cdk.core==1.204.0 aws-cdk.aws-codecommit==1.204.0 aws-cdk.aws-sns==1.204.0 aws-cdk-aws-codestarnotifications==1.204.0","lang":"bash","label":"Install with common dependencies for example"}],"dependencies":[{"reason":"Required for all CDK v1 applications; must match the exact version of the construct library.","package":"aws-cdk.core","optional":false},{"reason":"Commonly used as a source for CodeStar Notifications.","package":"aws-cdk.aws-codecommit","optional":true},{"reason":"Commonly used as a target for CodeStar Notifications.","package":"aws-cdk.aws-sns","optional":true}],"imports":[{"symbol":"NotificationRule","correct":"from aws_cdk import aws_codestarnotifications as notifications"},{"symbol":"DetailType","correct":"from aws_cdk import aws_codestarnotifications as notifications"}],"quickstart":{"code":"import os\nfrom aws_cdk import (\n    aws_codecommit as codecommit,\n    aws_sns as sns,\n    aws_codestarnotifications as notifications,\n    core as cdk\n)\n\nclass CodeStarNotificationsExampleStack(cdk.Stack):\n    def __init__(self, scope: cdk.App, id: str, **kwargs) -> None:\n        super().__init__(scope, id, **kwargs)\n\n        # Create a CodeCommit repository as the source for notifications\n        repo = codecommit.Repository(self, \"MyCodeCommitRepo\",\n            repository_name=\"my-app-repository-for-notifications\"\n        )\n\n        # Create an SNS topic as the target for notifications\n        # In a real scenario, you'd likely subscribe an email or Lambda to this topic.\n        notification_topic = sns.Topic(self, \"MyNotificationTopic\")\n\n        # Create a Notification Rule\n        # This rule will send notifications to the SNS topic for specific CodeCommit events.\n        notifications.NotificationRule(self, \"RepoNotificationRule\",\n            source=repo,\n            events=[\n                \"codecommit-repository-comments-on-commits\",\n                \"codecommit-repository-pull-request-created\",\n                \"codecommit-repository-pull-request-merged\"\n            ],\n            targets=[notification_topic],\n            detail_type=notifications.DetailType.FULL # Or DetailType.BASIC\n        )\n\n# Example of how to synthesize this stack (usually in app.py)\n# app = cdk.App()\n# CodeStarNotificationsExampleStack(app, \"CodeStarNotificationsExampleStack\")\n# app.synth()","lang":"python","description":"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."},"warnings":[{"fix":"For 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`.","message":"AWS 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.","severity":"breaking","affected_versions":"All v1.x vs v2.x"},{"fix":"Plan and execute a migration to AWS CDK v2 for new and existing projects to benefit from ongoing support and new features.","message":"AWS 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.","severity":"deprecated","affected_versions":"All v1.x"},{"fix":"Ensure 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`.","message":"Mixing 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.","severity":"gotcha","affected_versions":"All v1.x"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure 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`.","cause":"The package `aws-cdk-aws-codestarnotifications` is not installed, or `aws-cdk.core` is not installed, or Python environment path issues.","error":"ModuleNotFoundError: No module named 'aws_cdk.aws_codestarnotifications'"},{"fix":"Verify 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.","cause":"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`.","error":"TypeError: Argument 'source' must be an instance of <class 'aws_cdk.aws_codecommit.Repository'>"},{"fix":"Double-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.","cause":"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.","error":"AttributeError: module 'aws_cdk.aws_codestarnotifications' has no attribute 'NotificationRule'"}]}