Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-cdk/aws-ecr

Package Overview
Dependencies
Maintainers
5
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-cdk/aws-ecr

The CDK Construct Library for AWS::ECR

  • 1.87.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
144K
increased by13.5%
Maintainers
5
Weekly downloads
 
Created

What is @aws-cdk/aws-ecr?

@aws-cdk/aws-ecr is an AWS Cloud Development Kit (CDK) library that allows you to define and manage Amazon Elastic Container Registry (ECR) resources using code. ECR is a fully managed Docker container registry that makes it easy to store, manage, and deploy Docker container images.

What are @aws-cdk/aws-ecr's main functionalities?

Create a new ECR Repository

This code sample demonstrates how to create a new ECR repository named 'my-repo' using the AWS CDK.

const ecr = require('@aws-cdk/aws-ecr');
const cdk = require('@aws-cdk/core');

class MyStack extends cdk.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    new ecr.Repository(this, 'MyRepository', {
      repositoryName: 'my-repo'
    });
  }
}

const app = new cdk.App();
new MyStack(app, 'MyStack');

Add lifecycle policy to ECR Repository

This code sample demonstrates how to add a lifecycle policy to an ECR repository to retain only the last 5 images with the 'prod' tag.

const ecr = require('@aws-cdk/aws-ecr');
const cdk = require('@aws-cdk/core');

class MyStack extends cdk.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    const repository = new ecr.Repository(this, 'MyRepository', {
      repositoryName: 'my-repo'
    });

    repository.addLifecycleRule({
      tagPrefixList: ['prod'],
      maxImageCount: 5
    });
  }
}

const app = new cdk.App();
new MyStack(app, 'MyStack');

Grant permissions to a user

This code sample demonstrates how to grant pull permissions to an IAM user for an ECR repository.

const ecr = require('@aws-cdk/aws-ecr');
const iam = require('@aws-cdk/aws-iam');
const cdk = require('@aws-cdk/core');

class MyStack extends cdk.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    const repository = new ecr.Repository(this, 'MyRepository', {
      repositoryName: 'my-repo'
    });

    const user = new iam.User(this, 'MyUser');

    repository.grantPull(user);
  }
}

const app = new cdk.App();
new MyStack(app, 'MyStack');

Other packages similar to @aws-cdk/aws-ecr

Keywords

FAQs

Package last updated on 28 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc