Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform ECR 구현 #13

Closed
6 tasks done
Tracked by #1
junha-ahn opened this issue Aug 8, 2023 · 1 comment · Fixed by #22
Closed
6 tasks done
Tracked by #1

Terraform ECR 구현 #13

junha-ahn opened this issue Aug 8, 2023 · 1 comment · Fixed by #22
Labels
Major Major topic

Comments

@junha-ahn
Copy link
Member

junha-ahn commented Aug 8, 2023

Description

To do

  • Create ECR by Terraform
  • Backend Docker image push by git actions

Test Checklist

  • 1. koboot repo에서 push 테스트
  • 1. koboot에 잘못된 IAM USER로 push 테스트
  • 2. EKS에서 pull 테스트
  • 3. backend에 push 적용

EKS에서 배포 가능 확인

      containers:
      - image: domain.com/ticketing-ecr:latest
        name: kotlin-app
        ports:
        - containerPort: 80

IAM pull 권한 설정 없이 EKS에서 pull 가능

  • 같은 VPC이기 때문에 가능한건가?
  • 일단 public하게 open된건 아닌것으로 확인
# my local pc
$ docker pull 213060417361.dkr.ecr.ap-northeast-2.amazonaws.com/ticketing-ecr:6726449abe185748f6079e5503063e5ea55d4537
Error response from daemon: Head "https://213060417361.dkr.ecr.ap-northeast-2.amazonaws.com/v2/ticketing-ecr/manifests/6726449abe185748f6079e5503063e5ea55d4537": no basic auth credentials
@junha-ahn junha-ahn mentioned this issue Aug 8, 2023
8 tasks
@junha-ahn junha-ahn assigned junha-ahn and unassigned junha-ahn Aug 8, 2023
@junha-ahn
Copy link
Member Author

junha-ahn commented Aug 10, 2023

module "ecr" {
  source = "terraform-aws-modules/ecr/aws"

  repository_name = "private-example"

  repository_read_write_access_arns = ["arn:aws:iam::012345678901:role/terraform"]

  repository_lifecycle_policy = jsonencode({
    rules = [
      {
        rulePriority = 1,
        description  = "Keep last 30 images",
        selection = {
          tagStatus     = "tagged",
          tagPrefixList = ["v"],
          countType     = "imageCountMoreThan",
          countNumber   = 30
        },
        action = {
          type = "expire"
        }
      }
    ]
  })

  tags = {
    Terraform   = "true"
    Environment = "dev"
  }
}

해석

repository_read_write_access_arns

  • The ARNs of the IAM users/roles that have read/write access to the repository
  • list(string)

AWS ARN은 "Amazon Resource Name"의 약자로, AWS 리소스를 고유하게 식별하고 명명하는 데 사용되는 형식화된 문자열. ARN은 AWS의 여러 서비스에서 리소스를 식별하는 데 사용되며, 이를 통해 정확한 리소스를 지정하고 권한을 관리할 수 있습니다.

IAM 리소스의 ARN은 다음과 같은 형식을 가집니다:

  • IAM 사용자 ARN: arn:aws:iam::account-ID-without-hyphens:user/username
  • IAM 그룹 ARN: arn:aws:iam::account-ID-without-hyphens:group/groupname
  • IAM 역할 ARN: arn:aws:iam::account-ID-without-hyphens:role/rolename

repository_lifecycle_policy

IAM Role

Pirvate ECR 생성 후

  1. PUSH (- git actions)
  2. READ (- by ArgoCD)

PUSH 권한용 IAM 그룹 생성 후 repository_read_write_access_arns 설정

READ 권한용 IAM 그룹 생성 후 repository_read_access_arns 설정

@junha-ahn junha-ahn linked a pull request Aug 13, 2023 that will close this issue
@junha-ahn junha-ahn added the Major Major topic label Aug 28, 2023
@junha-ahn junha-ahn moved this to Done in Kanban Infra Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Major Major topic
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant