[CI/CD] Github Action + AWS Elastic Beanstalk + ECR + IAM + Docker + ARM + Java or Kotlin + Spring Boot + Gradle 배포 (2)
해당 자료는 총 5개 파트로 나누어서 자료를 정리할 예정이다.
part 1. IAM user 권한 설정
part 2. ECR repo 세팅
part 3. EB 설정 후 샘플 코드 서버 세팅
part 4. Spring Boot 프로젝트 내부 설정
part 5. github action 세팅
Part 2. ECR repo 세팅
part 1을 못 보셨다면 먼저 보시길 바란다.
https://dexlee.tistory.com/169
1. ECR(Elastic Container Registry) 특징
- 간단하게 설명하면 docker container의 이미지를 저장하는 repository 서비스이다.
- ECR은 aws가 제공하는 여러 container 서비스를 편하게 사용하기 위해 private repository를 제공하는 서비스이다.
- AWS IAM 인증을 통해 이미지 push or pull에 대한 권한 관리가 가능
2. ECR 생성
리포지토리 생성 클릭
리포지토리 생성 클릭
3. 만든 registry : permissions 설정
- 해당 저장소에 접근 가능하다고 유저를 설정해줘야 다른 aws 서비스에서 이미지를 컨트롤할 수 있다.
Permissions > 정책 JSON 편집 클릭
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "GetAuthorizationToken",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam:: iam user arn 정보"
},
"Action": "ecr:GetAuthorizationToken"
},
{
"Sid": "AllowPushAndPull",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam:: iam user arn 정보"
},
"Action": [
"ecr:BatchCheckLayerAvailability",
"ecr:BatchGetImage",
"ecr:CompleteLayerUpload",
"ecr:GetDownloadUrlForLayer",
"ecr:InitiateLayerUpload",
"ecr:PutImage",
"ecr:UploadLayerPart"
]
}
]
}
해당 유저에 대해 token과 push, pull를 허용해줘야 다른 aws 서비스에서 ecr에 접근 가능하다.
ps. 다음 시간에는 EB 세팅에 대해 다루겠습니다.
references
1) ecr 이란
https://docs.aws.amazon.com/ko_kr/AmazonECR/latest/userguide/image-scanning.html
https://docs.aws.amazon.com/ko_kr/AmazonECR/latest/userguide/what-is-ecr.html
2) ecr scan 취약점 파악
https://docs.aws.amazon.com/ko_kr/AmazonECR/latest/userguide/image-scanning.html
3) ecr kms 키 이미지 암호화
https://aws.amazon.com/ko/about-aws/whats-new/2020/07/ecr-supports-encryption-images-aws-kms-keys/
4) ecr permissions
https://docs.aws.amazon.com/AmazonECR/latest/userguide/security-iam-awsmanpol.html
https://docs.aws.amazon.com/AmazonECR/latest/userguide/repository-policies.html