An open API service indexing awesome lists of open source software.

https://github.com/greathayat/aws-ecr-docker

This repository will help you to understand, how to push your docker image to AWS ECR
https://github.com/greathayat/aws-ecr-docker

aws aws-containers aws-ecr aws-iam aws-iam-policies docker docker-image private-docker-registry

Last synced: 3 months ago
JSON representation

This repository will help you to understand, how to push your docker image to AWS ECR

Awesome Lists containing this project

README

          

# AWS ECR

`This repository will help you to understand, how to push your docker images to AWS ECR using Github actions`

## STEPS

1. CREATE PRIVATE REPOSITORY IN ECR

- Login to you AWS account
- Go to `AWS Container Registry` service and create a `private` repository
- Create Private Repository with a suitable name

2. CREATE IAM USER

- Create IAM user and create an inline policy
- An Inline policy will allow the IAM user to login to ECR, build and tag docker images and push docker images to `AWS ECR`

### Policy Examples

1. The following policy will enable user to push docker images to `any ECR registry`

```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecr:CompleteLayerUpload",
"ecr:GetAuthorizationToken",
"ecr:UploadLayerPart",
"ecr:InitiateLayerUpload",
"ecr:BatchCheckLayerAvailability",
"ecr:PutImage"
],
"Resource": "*"
}
]
}
```

2. The following policy will enable/restrict user to push docker images to a `specific ECR registry`

```
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecr:CompleteLayerUpload",
"ecr:UploadLayerPart",
"ecr:InitiateLayerUpload",
"ecr:BatchCheckLayerAvailability",
"ecr:PutImage"
],
"Resource": "arn:aws:ecr:region:111122223333:repository/repository-name"
},
{
"Effect": "Allow",
"Action": "ecr:GetAuthorizationToken",
"Resource": "*"
}
]
}
```

## How to use the Github Action workFlow (used in this repository)

Set the following secret variables in your repository secrets

- `AWS_ACCESS_KEY_ID`
- `AWS_SECREST_ACCESS_KEY`
- `AWS_ECR_REGION`
- `ECR_REPOSITORY_NAME`

#### HAPPY CLOUD LEARNING