Coder Social home page Coder Social logo

aws-ecr-public's Introduction

Public AWS Elastic Container Registry

Host any Elastic Container Registry (ECR) publicly on a custom domain using this serverless proxy.

Give it a spin:

# pull a container from a registry named nginx with no authentication
docker pull v3iomfy255.execute-api.us-east-2.amazonaws.com/nginx:alpine

Solution Overview

ECR doesn't support public registries. Instead, the docker client needs to authenticate with ECR using AWS IAM credentials which requires the AWS CLI or an SDK that can generate those credentials.

If you would like to make your registries publicly available then this solution can help. It deploys an API Gateway and a Lambda function that act as a proxy for AWS ECR. Custom authentication can easily be added in the API Gateway. Roll your own JWT-based authentication or whatever you desire. Additionally, you can configure the API Gateway to be private and thus limit access to docker clients within your VPC.

diagram

Deploy

launch

Download Template

Template Parameters

Parameter Required Description
DomainName No If provided an ACM Certificate and API Domain Name will be created
ValidationDomain No Overwrite default Validation Domain for ACM Certificate
ValidationMethod Yes, Default: EMAIL Allow you to use DNS instead of EMAIL for Certificate validation

FAQ

How can I host this proxy on a custom domain?

Simply provide the DomainName parameter when you create the stack. This will create an ACM certificate and API Domain Name resource. The Regional Domain Name and Hosted Zone ID can be found in the outputs tab of the stack. You will need those to create the DNS record in Route 53 (or similar DNS service).

For Route 53, open your hosted zone, create a New Record Set, enter the domain name, set Alias to Yes and paste the RegionalDomainName in the Alias Target field.

How can I restrict access to certain registries?

By default all registries in the account and region will be made publicly available. To limit the number of publicly available repositores, attach a custom policy to the Lambda execution role (look for ${AWS::StackName}-LambdaRole-*). The following policy will restrict public access to the myapp repository (make sure you replace the variables with your region and account id).

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "ecr:GetDownloadUrlForLayer",
                "ecr:BatchGetImage"
            ],
            "NotResource": [
                "arn:aws:ecr:${AWS::Region}:${AWS::AccountId}:repository/myapp"
            ],
            "Effect": "Deny"
        }
    ]
}

Develop

npm install --global cfn-include
make build
make test  # create/update CloudFormation stack
make clean # delete CloudFormation stack

In the works

  • Cross-account and cross-region access to registries
  • Tag-based permissions
  • Implement additional endpoints for listing images and tags

aws-ecr-public's People

Contributors

monken avatar jgjorgji avatar christopherhein avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.