AWS CDK ECR Construct Library (v1)

1.204.0 · abandoned · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

import os
from aws_cdk import (
    core as cdk,
    aws_ecr as ecr
)

class ECRStackV1(cdk.Stack):
    def __init__(self, scope: cdk.Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        # Create an ECR repository
        repository = ecr.Repository(self, "MyRepositoryV1",
            repository_name="my-application-images-v1"
        )

        cdk.CfnOutput(self, "RepositoryUri", value=repository.repository_uri)

app = cdk.App()
ECRStackV1(app, "ECRStackV1",
    env=cdk.Environment(
        account=os.environ.get('CDK_DEFAULT_ACCOUNT', os.environ.get('AWS_ACCOUNT_ID')),
        region=os.environ.get('CDK_DEFAULT_REGION', os.environ.get('AWS_REGION', 'us-east-1'))
    )
)
app.synth()

# NOTE: This quickstart is for AWS CDK v1, which is End-of-Support. 
# For AWS CDK v2, the import paths and package structure are different. 
# You should migrate to v2 and use `from aws_cdk import aws_ecr`.

view raw JSON →