Skip to content

Commit

Permalink
add custom policy var (#23)
Browse files Browse the repository at this point in the history
* add custom policy var
  • Loading branch information
FriedCircuits authored Nov 17, 2022
1 parent d4dd26e commit 23a0907
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.0.19
v0.0.20
19 changes: 19 additions & 0 deletions modules/github/actions-secrets/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,22 @@ resource "aws_iam_user_policy" "github" {

policy = data.aws_iam_policy_document.github[0].json
}

resource "aws_iam_user_policy" "custom" {
count = var.create_aws_iam_user == true ? 1 : 0
name = "custom-policies"
user = aws_iam_user.github[0].name

policy = data.aws_iam_policy_document.custom[0].json
}
data "aws_iam_policy_document" "custom" {
count = var.create_aws_iam_user == true ? 1 : 0
dynamic "statement" {
for_each = { for statement in var.aws_iam_custom_policies : statement.sid => statement }
content {
sid = statement.value.sid
actions = statement.value.actions
resources = statement.value.resources
}
}
}
4 changes: 4 additions & 0 deletions modules/github/actions-secrets/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
output "github_public_key" {
value = data.github_actions_public_key.public_key
}

output "aws_iam_user_arn" {
value = try(aws_iam_user.github[0].arn, "no iam user")
}
10 changes: 10 additions & 0 deletions modules/github/actions-secrets/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ variable "aws_iam_user_name" {
default = "github-terraform-backend"
}

variable "aws_iam_custom_policies" {
description = "Extra policy statements to add to IAM user."
type = list(object({
sid = string
actions = list(string)
resources = list(string)
}))
default = []
}

variable "terraform_bucket_name" {
description = "Terraform backend bucket name for IAM policy."
type = string
Expand Down

0 comments on commit 23a0907

Please sign in to comment.