Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Commit 640038c

Browse files
committed
Get working aws roles for github
1 parent 360d73a commit 640038c

File tree

2 files changed

+17
-45
lines changed

2 files changed

+17
-45
lines changed

terraform/ecr.tf

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -31,48 +31,3 @@ resource "aws_ecr_lifecycle_policy" "sync_svc_cube_lf_policy" {
3131
EOF
3232
}
3333

34-
35-
data "aws_iam_policy_document" "sync_svc_cube_policy" {
36-
statement {
37-
sid = "All Accounts in the Org can pull"
38-
effect = "Allow"
39-
principals {
40-
type = "AWS"
41-
identifiers = ["*"]
42-
}
43-
actions = [
44-
"ecr:GetDownloadUrlForLayer",
45-
"ecr:BatchGetImage",
46-
"ecr:ListImages"
47-
]
48-
condition {
49-
test = "StringEquals"
50-
variable = "aws:PrincipalAccount"
51-
values = ["${var.aws_account_id}"]
52-
}
53-
}
54-
statement {
55-
sid = "Allow push only from github actions"
56-
effect = "Allow"
57-
principals {
58-
type = "AWS"
59-
identifiers = ["${module.iam_github_oidc_role.arn}"]
60-
}
61-
actions = ["ecr:BatchCheckLayerAvailability",
62-
"ecr:CompleteLayerUpload",
63-
"ecr:InitiateLayerUpload",
64-
"ecr:PutImage",
65-
"ecr:UploadLayerPart"]
66-
condition {
67-
test = "StringEquals"
68-
variable = "aws:PrincipalAccount"
69-
values = ["${var.aws_account_id}"]
70-
}
71-
}
72-
}
73-
74-
resource "aws_ecr_repository_policy" "sync_svc_cube_repo_policy" {
75-
repository = aws_ecr_repository.sync_svc_cube_repo.name
76-
policy = data.aws_iam_policy_document.sync_svc_cube_policy.json
77-
}
78-

terraform/iam.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@ resource "aws_iam_policy" "sync_svc_cube_ecr_policy" {
5151
"ecr:UploadLayerPart"
5252
],
5353
"Resource" : aws_ecr_repository.sync_svc_cube_repo.arn
54+
},
55+
{
56+
"Sid" : "AllowTaskDefinitionUpdates",
57+
"Effect" : "Allow",
58+
"Action" : [
59+
"ecs:DescribeTaskDefinition",
60+
"ecs:RegisterTaskDefinition"
61+
],
62+
"Resource" : "*"
63+
},
64+
{
65+
"Sid" : "AllowPassRoleToTask",
66+
"Effect" : "Allow",
67+
"Action" : [
68+
"iam:PassRole"
69+
],
70+
"Resource" : [aws_iam_role.ecs_task_role.arn, aws_iam_role.ecs_task_execution_role.arn]
5471
}
5572
]
5673
})

0 commit comments

Comments
 (0)