Skip to content

Commit 080c3bc

Browse files
authored
Merge pull request #5 from Intelliflo/update-policies
fix: update policies
2 parents 3be45e2 + 828552f commit 080c3bc

File tree

5 files changed

+74
-80
lines changed

5 files changed

+74
-80
lines changed

images/ubuntu-focal/github_agent.ubuntu.pkr.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ source "amazon-ebs" "githubrunner" {
104104
associate_public_ip_address = var.associate_public_ip_address
105105
temporary_security_group_source_public_ip = var.temporary_security_group_source_public_ip
106106

107-
ssh_interface = "session_manager"
107+
ssh_interface = "session_manager" # needed because tower control is blocking port 22
108108
iam_instance_profile = "AmazonSSMRoleForInstancesQuickSetup"
109109

110110
source_ami_filter {

modules/runners/policies-custom.tf

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
resource "aws_iam_role_policy" "gh_artifacts_bucket" {
2+
name = "github-ci-loop-artifacts-bucket"
3+
role = aws_iam_role.runner.name
4+
policy = jsonencode({
5+
Version = "2012-10-17"
6+
Statement = [
7+
{
8+
Sid = "githubActionArtifacts",
9+
Action = [
10+
"s3:ListBucket",
11+
"s3:GetObject",
12+
"s3:GetObjectTagging",
13+
"s3:DeleteObject",
14+
"s3:PutObject",
15+
"s3:PutObjectAcl",
16+
"s3:PutObjectTagging"
17+
]
18+
Effect = "Allow"
19+
Resource = [
20+
"arn:aws:s3:::github-ci-loop-artifacts/*",
21+
"arn:aws:s3:::github-ci-loop-artifacts",
22+
"arn:aws:s3:::packages.shs-ie-01.intelliflo.services/*",
23+
"arn:aws:s3:::packages.shs-ie-01.intelliflo.services",
24+
"arn:aws:s3:::mssql-migrations.shs-ie-01.intelliflo.services/*",
25+
"arn:aws:s3:::mssql-migrations.shs-ie-01.intelliflo.services"
26+
]
27+
}
28+
]
29+
})
30+
}
31+
32+
resource "aws_iam_role_policy" "runner_ecr_scan_push_access" {
33+
name = "ecr-scan-push-access"
34+
role = aws_iam_role.runner.name
35+
policy = jsonencode({
36+
Version = "2012-10-17"
37+
Statement = [
38+
{
39+
Sid = "githubActionEcr",
40+
Action = [
41+
"ecr:DescribeImageScanFindings",
42+
"ecr:StartImageScan",
43+
"ecr:GetDownloadUrlForLayer",
44+
"ecr:DescribeRegistry",
45+
"ecr:GetAuthorizationToken",
46+
"ecr:ListTagsForResource",
47+
"ecr:UploadLayerPart",
48+
"ecr:BatchDeleteImage",
49+
"ecr:ListImages",
50+
"ecr:PutImage",
51+
"ecr:BatchGetImage",
52+
"ecr:CompleteLayerUpload",
53+
"ecr:DescribeImages",
54+
"ecr:DescribeRepositories",
55+
"ecr:InitiateLayerUpload",
56+
"ecr:BatchCheckLayerAvailability"
57+
]
58+
Effect = "Allow"
59+
Resource = "*"
60+
}
61+
]
62+
})
63+
}
64+
65+
resource "aws_iam_role_policy_attachment" "runner_code_artifact_admin_access" {
66+
role = aws_iam_role.runner.name
67+
policy_arn = "arn:aws:iam::aws:policy/AWSCodeArtifactAdminAccess"
68+
}
69+
70+
resource "aws_iam_role_policy_attachment" "runner_basic_ecr_access" {
71+
role = aws_iam_role.runner.name
72+
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSAppRunnerServicePolicyForECRAccess"
73+
}

modules/runners/policies-runner.tf

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,3 @@ resource "aws_iam_role_policy" "ec2" {
7171
}
7272

7373
# see also logging.tf for logging and metrics policies
74-
75-
resource "aws_iam_role_policy" "gh_artifacts_bucket" {
76-
name = "github-ci-loop-artifacts-bucket"
77-
role = aws_iam_role.runner.name
78-
policy = templatefile("${path.module}/policies/instance-s3-gh-policy.json",
79-
{
80-
s3_arn = "arn:aws:s3:::github-ci-loop-artifacts"
81-
s3_packages_arn = "arn:aws:s3:::packages.shs-ie-01.intelliflo.services"
82-
}
83-
)
84-
}
85-
86-
resource "aws_iam_role_policy" "runner_ecr_scan_push_access" {
87-
name = "ecr-scan-push-access"
88-
role = aws_iam_role.runner.name
89-
policy = file("${path.module}/policies/instance-ecr-gh-policy.json")
90-
}
91-
92-
resource "aws_iam_role_policy_attachment" "runner_code_artifact_admin_access" {
93-
role = aws_iam_role.runner.name
94-
policy_arn = "arn:aws:iam::aws:policy/AWSCodeArtifactAdminAccess"
95-
}
96-
97-
resource "aws_iam_role_policy_attachment" "runner_basic_ecr_access" {
98-
role = aws_iam_role.runner.name
99-
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSAppRunnerServicePolicyForECRAccess"
100-
}

modules/runners/policies/instance-ecr-gh-policy.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

modules/runners/policies/instance-s3-gh-policy.json

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)