{"id":9512,"library":"aws-cdk-aws-codecommit","title":"AWS CDK Construct Library for CodeCommit","description":"The `aws-cdk-aws-codecommit` library provides AWS Cloud Development Kit (CDK) constructs for defining AWS CodeCommit resources programmatically using Python. It allows developers to create, configure, and manage CodeCommit repositories as part of their infrastructure-as-code deployments. This entry specifically covers version 1.204.0, which is part of the AWS CDK v1 ecosystem. AWS CDK typically follows a rapid release cadence, often with weekly updates for bug fixes and new feature support.","status":"active","version":"1.204.0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-cdk.git","tags":["aws","cdk","codecommit","infrastructure-as-code","cloud-development-kit","iac"],"install":[{"cmd":"pip install aws-cdk-aws-codecommit aws-cdk.core","lang":"bash","label":"Install library and core CDK"},{"cmd":"npm install -g aws-cdk","lang":"bash","label":"Install CDK Toolkit (Node.js)"}],"dependencies":[{"reason":"Required for core CDK constructs like App, Stack, and runtime environment.","package":"aws-cdk.core","optional":false}],"imports":[{"note":"This package is for AWS CDK v1. The correct import pattern uses an alias for the module, then accesses classes through that alias. The direct `from ... import ClassName` is the v2 pattern and will cause an AttributeError in v1.","wrong":"from aws_cdk.aws_codecommit import Repository","symbol":"Repository","correct":"from aws_cdk import aws_codecommit as codecommit\n# then: codecommit.Repository(...)"},{"note":"For CDK v1, `App` and `Stack` are typically imported from `aws_cdk.core`. The direct `from aws_cdk import App` is the v2 pattern.","wrong":"from aws_cdk import App","symbol":"App","correct":"from aws_cdk import core as cdk\n# then: cdk.App()"}],"quickstart":{"code":"import os\nfrom aws_cdk import (\n    core as cdk,\n    aws_codecommit as codecommit\n)\n\nclass CodeCommitStack(cdk.Stack):\n    def __init__(self, scope: cdk.App, construct_id: str, **kwargs) -> None:\n        super().__init__(scope, construct_id, **kwargs)\n\n        # Create a new CodeCommit repository\n        repo = codecommit.Repository(\n            self, \"MyCodeCommitRepo\",\n            repository_name=\"my-application-repo\"\n        )\n\n        # Output the repository clone URL for convenience\n        cdk.CfnOutput(\n            self, \"RepositoryCloneUrlHttp\",\n            value=repo.repository_clone_url_http,\n            description=\"HTTP URL to clone the CodeCommit repository\"\n        )\n\napp = cdk.App()\nCodeCommitStack(\n    app, \"CodeCommitQuickstartStack\",\n    env=cdk.Environment(\n        account=os.environ.get(\"CDK_DEFAULT_ACCOUNT\", \"\"),\n        region=os.environ.get(\"CDK_DEFAULT_REGION\", \"us-east-1\")\n    )\n)\napp.synth()","lang":"python","description":"This quickstart defines a basic AWS CDK application that creates a new AWS CodeCommit repository. It includes standard CDK v1 import patterns and outputs the HTTP clone URL for the created repository. Remember to set your AWS credentials and region, either via environment variables (`CDK_DEFAULT_ACCOUNT`, `CDK_DEFAULT_REGION`) or AWS CLI configuration."},"warnings":[{"fix":"If starting a new project, consider using AWS CDK v2 (install `aws-cdk-lib` and specific service packages). If maintaining a v1 project, ensure all CDK packages are pinned to v1 versions (e.g., `aws-cdk.core==1.x.x`). For migration, consult the official AWS CDK v2 migration guide.","message":"This package (`aws-cdk-aws-codecommit==1.204.0`) is part of AWS CDK v1. AWS CDK v2 is the current major version, which introduces significant breaking changes, especially in import paths (`aws-cdk.core` is replaced by `aws_cdk.lib`) and module structure. Code written for v1 is not directly compatible with v2.","severity":"breaking","affected_versions":"All versions >= 2.0.0 (for migration)"},{"fix":"Install the AWS CDK Toolkit: `npm install -g aws-cdk` and ensure Node.js is correctly set up in your PATH.","message":"CDK applications require the AWS CDK Toolkit (CLI) to be installed globally via Node.js (`npm install -g aws-cdk`). Without it, commands like `cdk synth` or `cdk deploy` will fail.","severity":"gotcha","affected_versions":"All versions of AWS CDK"},{"fix":"Choose a unique and descriptive name for your CodeCommit repository. If deploying multiple instances of the same stack (e.g., for different environments), use context values or a naming convention to ensure uniqueness (e.g., `my-app-repo-dev`, `my-app-repo-prod`).","message":"The `repository_name` property for a CodeCommit repository must be unique within an AWS account and region. Attempting to deploy a stack with a duplicate repository name will result in a deployment failure.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always import `core` as an alias (e.g., `import aws_cdk.core as cdk` or `from aws_cdk import core as cdk`) and use `cdk.App()`, `cdk.Stack()`, etc., for v1 projects.","message":"CDK v1 requires an explicit `from aws_cdk import core as cdk` or similar alias for core components like `App` and `Stack`. Many examples on the web for CDK v2 might show `from aws_cdk import App, Stack`, which will not work with v1.","severity":"gotcha","affected_versions":"AWS CDK v1"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure `aws-cdk.core` is installed: `pip install aws-cdk.core`.","cause":"The core AWS CDK library, `aws-cdk.core`, is not installed or available in the Python environment.","error":"ModuleNotFoundError: No module named 'aws_cdk.core'"},{"fix":"For CDK v1, use `from aws_cdk import aws_codecommit as codecommit` and then refer to the class as `codecommit.Repository`.","cause":"This typically occurs when trying to use the CDK v2 import style (`from aws_cdk.aws_codecommit import Repository`) with a CDK v1 package (`aws-cdk-aws-codecommit`).","error":"AttributeError: module 'aws_cdk.aws_codecommit' has no attribute 'Repository'"},{"fix":"Ensure you provide a `repository_name` when instantiating `codecommit.Repository`: `codecommit.Repository(self, 'MyRepo', repository_name='my-unique-repo-name')`.","cause":"The `repository_name` property is a required parameter when defining a `codecommit.Repository` construct.","error":"jsii.errors.JavaScriptError: repositoryName must be specified. (Service: CodeCommit, Status Code: 400, Request ID: ...)"},{"fix":"Configure your AWS environment: `export CDK_DEFAULT_REGION=us-east-1` (or your desired region) and `export CDK_DEFAULT_ACCOUNT=$(aws sts get-caller-identity --query 'Account' --output text)`.","cause":"The CDK application or CLI cannot determine which AWS region to deploy to. This often happens if `CDK_DEFAULT_REGION` is not set or AWS CLI is not configured.","error":"Error: Resolution error: Resolution error: No default region is configured. Please configure a default region."}]}