{"id":14441,"library":"aws-cdk-aws-ecr","title":"AWS CDK ECR Construct Library (v1)","description":"This is the AWS Cloud Development Kit (CDK) v1 construct library for Amazon Elastic Container Registry (ECR). It provides high-level constructs to define ECR resources using familiar programming languages. As of June 1, 2023, AWS CDK v1 has reached End-of-Support, meaning this package is no longer updated, and users are strongly advised to migrate to AWS CDK v2. In v2, ECR constructs are part of the unified `aws-cdk-lib` package.","status":"abandoned","version":"1.204.0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-cdk.git","tags":["aws","cdk","ecr","iac","infrastructure-as-code","deprecated","v1"],"install":[{"cmd":"pip install aws-cdk.aws-ecr","lang":"bash","label":"Install (CDK v1)"},{"cmd":"pip install aws-cdk-lib constructs","lang":"bash","label":"Install (CDK v2 - Recommended)"}],"dependencies":[{"reason":"Core CDK functionalities for v1 constructs.","package":"aws-cdk.core","optional":false},{"reason":"Required for all CDK applications, including v1 and v2.","package":"constructs","optional":false}],"imports":[{"note":"CDK v1 typically uses `import aws_cdk.aws_ecr as ecr` while v2 consolidates to `aws_cdk.aws_ecr` directly under `aws_cdk` or `aws_cdk_lib.aws_ecr`.","wrong":"from aws_cdk.aws_ecr import Repository","symbol":"Repository","correct":"from aws_cdk import aws_ecr as ecr\n# For CDK v2, use:\n# from aws_cdk import aws_ecr"}],"quickstart":{"code":"import os\nfrom aws_cdk import (\n    core as cdk,\n    aws_ecr as ecr\n)\n\nclass ECRStackV1(cdk.Stack):\n    def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:\n        super().__init__(scope, construct_id, **kwargs)\n\n        # Create an ECR repository\n        repository = ecr.Repository(self, \"MyRepositoryV1\",\n            repository_name=\"my-application-images-v1\"\n        )\n\n        cdk.CfnOutput(self, \"RepositoryUri\", value=repository.repository_uri)\n\napp = cdk.App()\nECRStackV1(app, \"ECRStackV1\",\n    env=cdk.Environment(\n        account=os.environ.get('CDK_DEFAULT_ACCOUNT', os.environ.get('AWS_ACCOUNT_ID')),\n        region=os.environ.get('CDK_DEFAULT_REGION', os.environ.get('AWS_REGION', 'us-east-1'))\n    )\n)\napp.synth()\n\n# NOTE: This quickstart is for AWS CDK v1, which is End-of-Support. \n# For AWS CDK v2, the import paths and package structure are different. \n# You should migrate to v2 and use `from aws_cdk import aws_ecr`.","lang":"python","description":"This quickstart demonstrates creating a basic ECR repository using the `aws-cdk-aws-ecr` (v1) construct. It defines a stack that provisions an ECR repository named 'my-application-images-v1'. It is crucial to note that this is a v1 example, and migration to AWS CDK v2 is strongly recommended."},"warnings":[{"fix":"Migrate your CDK applications to AWS CDK v2. For ECR functionality, use `aws-cdk-lib` and `from aws_cdk import aws_ecr` for imports.","message":"AWS CDK v1 reached End-of-Support on June 1, 2023. This package (aws-cdk.aws-ecr) is no longer being updated, and new features, bug fixes, or security patches will not be released.","severity":"breaking","affected_versions":"1.x"},{"fix":"Update your `requirements.txt` to `aws-cdk-lib` and `constructs`, and change import statements from `import aws_cdk.aws_ecr as ecr` to `from aws_cdk import aws_ecr`.","message":"CDK v2 consolidates all stable constructs into a single `aws-cdk-lib` package. This changes import statements from `@aws-cdk/aws-service` style (v1) to `aws_cdk.aws_service` (v2) for Python.","severity":"breaking","affected_versions":"1.x (when migrating to 2.x)"},{"fix":"Globally update `aws-cdk` CLI to v2 (`npm install -g aws-cdk@latest`) and re-bootstrap your AWS account (`cdk bootstrap`). Ensure your deployment roles have updated permissions for v2 assets if you use fine-grained access.","message":"AWS CDK v2 requires a new version of the CDK Toolkit (CLI) and a re-bootstrap of your AWS environment with the modern bootstrap stack. Deploying v1 stacks with v2 CLI or vice-versa can lead to incompatibilities.","severity":"breaking","affected_versions":"1.x (when migrating to 2.x)"},{"fix":"Remove most v1 feature flags from `cdk.json` that start with `@aws-cdk/`. A small subset can be set to `false` to revert to specific v1 behaviors if necessary, but review the migration guide carefully.","message":"Feature flags in `cdk.json` from v1 projects are largely deprecated in v2. Leaving them in can cause unexpected behavior or prevent new v2 defaults from applying.","severity":"gotcha","affected_versions":"1.x (when migrating to 2.x)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"For CDK v2: Ensure `aws-cdk-lib` is installed (`pip install aws-cdk-lib`) and imports are `from aws_cdk import aws_ecr`. For CDK v1: Ensure `aws-cdk.aws-ecr` is installed (`pip install aws-cdk.aws-ecr`) and imports are `import aws_cdk.aws_ecr as ecr`. Best practice is to migrate to v2.","cause":"Attempting to use `aws_cdk.aws_ecr` import style (common in v2) without `aws-cdk-lib` installed, or with only the v1 `aws-cdk.aws-ecr` package. Alternatively, trying v1 imports like `aws_cdk.aws_ecr` with `aws-cdk-lib` installed, but the specific v1 package is missing.","error":"ModuleNotFoundError: No module named 'aws_cdk.aws_ecr'"},{"fix":"Run `cdk bootstrap aws://ACCOUNT-ID/REGION` (e.g., `cdk bootstrap aws://123456789012/us-east-1`) to provision or update the modern bootstrap stack. Ensure your `aws-cdk` CLI is updated to v2.","cause":"Trying to deploy a CDK application without the required bootstrap stack in the target account/region, or the bootstrap stack is an older v1 version incompatible with a v2 CLI.","error":"RuntimeError: The CDK environment is not bootstrapped in the region 'us-east-1' for account '123456789012'. Please run 'cdk bootstrap aws://123456789012/us-east-1'."},{"fix":"First, ensure your environment is bootstrapped with the latest CDK v2 bootstrap stack (`cdk bootstrap`). If the issue persists, review the specific construct's documentation, as it might require explicit `asset_options` or `bundling` configurations (e.g., `bundling=cdk.BundlingOptions(image=cdk.DockerImage.from_registry(\"public.ecr.aws/lambda/python:3.9\"))`). This can also be a symptom of v1 constructs trying to build assets using v2 CLI, so migration to v2 is the ultimate fix.","cause":"This error often occurs when deploying Docker image-based Lambda functions or similar assets. In CDK v2, the asset handling mechanism changed, and older patterns or missing bootstrap resources can trigger this. It might indicate an incompatibility between the CDK CLI and the CDK library version being used, or an outdated bootstrap stack not configured for asset publishing.","error":"Assets must be enabled for this stack or a parent stack to use DockerImageFunction. If you are using 'aws-cdk-lib.aws_lambda_docker.DockerImageFunction', set 'bundling.local' to false in the construct props."}],"ecosystem":"pypi"}