Skip to content

Commit 0a1a260

Browse files
committed
eli-279 dealing with IAMs
1 parent c5acda9 commit 0a1a260

1 file changed

Lines changed: 50 additions & 19 deletions

File tree

infrastructure/stacks/iams-developer-roles/github_actions_policies.tf

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,9 @@ resource "aws_iam_policy" "s3_management" {
158158

159159
# API Infrastructure Management Policy
160160
resource "aws_iam_policy" "api_infrastructure" {
161-
#checkov:skip=CKV_AWS_355 Ensure no IAM policies documents allow "*" as a statement's resource for restrictable actions
162-
#checkov:skip=CKV_AWS_288 Ensure IAM policies does not allow data exfiltration
163-
#checkov:skip=CKV_AWS_289 Ensure IAM policies does not allow permissions management / resource exposure without constraints
164-
#checkov:skip=CKV_AWS_286 Ensure IAM policies does not allow privilege escalation
165-
#checkov:skip=CKV_AWS_290 Ensure IAM policies does not allow write access without constraints
161+
#checkov:skip=CKV_AWS_355 EC2 permissions allow all actions on all resources
162+
#checkov:skip=CKV_AWS_288 Role needs access to SSM and logs
163+
#checkov:skip=CKV_AWS_290 Write access limited to tags and network ACL entries
166164

167165
name = "api-infrastructure-management"
168166
description = "Policy granting permissions to manage API infrastructure"
@@ -186,20 +184,6 @@ resource "aws_iam_policy" "api_infrastructure" {
186184
"ec2:CreateTags",
187185
"ec2:CreateNetworkAclEntry",
188186

189-
# IAM permissions (scoped to resources with specific path prefix)
190-
"iam:Get*",
191-
"iam:GetPolicy*",
192-
"iam:GetRole*",
193-
"iam:List*",
194-
"iam:CreateRole",
195-
"iam:DeleteRole",
196-
"iam:UpdateRole",
197-
"iam:PutRolePolicy",
198-
"iam:PutRolePermissionsBoundary",
199-
"iam:AttachRolePolicy",
200-
"iam:DetachRolePolicy",
201-
"iam:CreatePolicyVersion",
202-
203187
# ssm
204188
"ssm:GetParameter",
205189
"ssm:GetParameters",
@@ -227,6 +211,48 @@ resource "aws_iam_policy" "api_infrastructure" {
227211
)
228212
}
229213

214+
# IAM Management Policy
215+
resource "aws_iam_policy" "iam_management" {
216+
name = "iam-management"
217+
description = "Policy granting permissions to manage only project-specific IAM roles and policies"
218+
path = "/service-policies/"
219+
220+
policy = jsonencode({
221+
Version = "2012-10-17",
222+
Statement = [
223+
{
224+
Effect = "Allow",
225+
Action = [
226+
"iam:Get*",
227+
"iam:GetPolicy*",
228+
"iam:GetRole*",
229+
"iam:List*",
230+
"iam:CreateRole",
231+
"iam:DeleteRole",
232+
"iam:UpdateRole",
233+
"iam:PutRolePolicy",
234+
"iam:PutRolePermissionsBoundary",
235+
"iam:AttachRolePolicy",
236+
"iam:DetachRolePolicy",
237+
"iam:CreatePolicyVersion"
238+
],
239+
Resource = [
240+
# Lambda role
241+
"arn:aws:iam::*:role/eligibility_lambda-role*",
242+
# API Gateway role
243+
"arn:aws:iam::*:role/*-api-gateway-*-role",
244+
# External write role
245+
"arn:aws:iam::*:role/eligibility-signposting-api-*-external-write-role",
246+
# Project policies
247+
"arn:aws:iam::*:policy/*api-gateway-logging-policy",
248+
"arn:aws:iam::*:policy/*PermissionsBoundary"
249+
]
250+
}
251+
]
252+
})
253+
tags = merge(local.tags, { Name = "iam-management" })
254+
}
255+
230256
# Assume role policy document for GitHub Actions
231257
data "aws_iam_policy_document" "github_actions_assume_role" {
232258
statement {
@@ -281,4 +307,9 @@ resource "aws_iam_role_policy_attachment" "s3_management" {
281307
policy_arn = aws_iam_policy.s3_management.arn
282308
}
283309

310+
resource "aws_iam_role_policy_attachment" "iam_management" {
311+
role = aws_iam_role.github_actions.name
312+
policy_arn = aws_iam_policy.iam_management.arn
313+
}
314+
284315
data "aws_caller_identity" "current" {}

0 commit comments

Comments
 (0)