Skip to content

Commit eda80a3

Browse files
authored
Merge pull request #26 from openbraininstitute/private_registry
Add policy to allow to pull a private image from certain identitites
2 parents 50410f2 + cb7f305 commit eda80a3

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,9 @@ module "public_ecr_github_actions_upload_credentials_notebook_service" {
338338
}
339339

340340
module "obi_notebook_image" {
341-
source = "./private-ecr-repo"
342-
repository_name = "obi-notebook-image"
341+
source = "./private-ecr-repo"
342+
repository_name = "obi-notebook-image"
343+
allowed_to_pull_identities = ["arn:aws:iam::992382665735:role/eksctl-jupyterhub-svc-nodegroup-ng-NodeInstanceRole-ZT1FeO9Ce2wc"]
343344
}
344345

345346
module "private_ecr_github_actions_upload_credentials_obi-notebook_image" {

private-ecr-repo/policy.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
data "aws_iam_policy_document" "allow_eks_pull_from_ecr" {
2+
statement {
3+
sid = "AllowEKSCrossAccountPullfromECR-${var.repository_name}"
4+
effect = "Allow"
5+
6+
principals {
7+
type = "AWS"
8+
identifiers = var.allowed_to_pull_identities
9+
}
10+
11+
actions = [
12+
"ecr:BatchCheckLayerAvailability",
13+
"ecr:BatchGetImage",
14+
"ecr:GetDownloadUrlForLayer"
15+
]
16+
}
17+
}
18+
19+
resource "aws_ecr_repository_policy" "allow_eks_pull_from_ecr" {
20+
repository = aws_ecr_repository.private_repo.name
21+
policy = data.aws_iam_policy_document.allow_eks_pull_from_ecr.json
22+
}

private-ecr-repo/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ variable "repository_name" {
33
description = "Name of the repository"
44
sensitive = false
55
}
6+
7+
variable "allowed_to_pull_identities" {
8+
type = list(any)
9+
description = "List of AWS identities that are allow to pull from the private repository"
10+
}

0 commit comments

Comments
 (0)