Skip to content

Commit

Permalink
Add support for adding additional policies to the capa controller role
Browse files Browse the repository at this point in the history
Both inline and managed policies can  be added
  • Loading branch information
iuriaranda committed Dec 31, 2024
1 parent 0e16a4f commit 48421c6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions capa-controller-role/giantswarm-capa-role.tf
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,16 @@ resource "aws_iam_role_policy_attachment" "giantswarm_crossplane_policy_attachme
role = aws_iam_role.giantswarm_capa_controller_role.name
policy_arn = aws_iam_policy.giantswarm_crossplane_policy.arn
}

resource "aws_iam_role_policy" "additional_inline_policies" {
for_each = var.additional_policies
name = each.key
role = aws_iam_role.giantswarm_capa_controller_role.name
policy = each.value
}

resource "aws_iam_role_policy_attachment" "additional_policy_attachments" {
for_each = toset(var.additional_policies_arns)
role = aws_iam_role.giantswarm_capa_controller_role.name
policy_arn = each.value
}
12 changes: 12 additions & 0 deletions capa-controller-role/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,15 @@ variable "import_existing" {
description = "If true, the existing role and policies will be imported instead of created"
default = false
}

variable "additional_policies" {
type = map(string)
description = "Map of additional policy documents to attach to the IAM role"
default = {}
}

variable "additional_policies_arns" {
type = list(string)
description = "List of ARNs of additional managed policies to attach to the role"
default = []
}

0 comments on commit 48421c6

Please sign in to comment.