@98kb/ecr-image-tagger-construct
v1.0.2
Published
An AWS CDK construct for automated ECR image tagging with stage tags during deployment.
Downloads
36
Maintainers
Readme
ECR Image Tagger Construct
AWS CDK construct for automated ECR image tagging with stage tags during deployment.
Usage
import { EcrImageTaggerConstruct } from '@mapp/ecr-image-tagger-construct';
const tagger = new EcrImageTaggerConstruct(this, 'EcrTagger', {
repositoryName: 'my-app-repository',
imageTag: '1.2.0',
stageTag: 'prod',
region: 'us-east-1' // optional
});
// Ensure tagging happens after successful deployment
myService.node.addDependency(tagger.customResource);Properties
interface EcrImageTaggerProps {
repositoryName: string; // ECR repository name
imageTag: string; // Source image tag to duplicate
stageTag: string; // Stage tag to apply (e.g., 'dev', 'uat', 'prod')
region?: string; // AWS region (defaults to current region)
}How it Works
- Retrieves the digest of the image being deployed
- Finds and removes the stage tag from any image currently using it
- Applies the stage tag to the new image being deployed
Each stage tag can only exist on one image at a time, but a single image can have multiple stage tags if deployed to multiple environments.
Development
pnpm run build # Build the constructIAM Permissions
The construct automatically creates the necessary IAM permissions for ECR operations.
