Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions github-oidc-iam-role/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ module "oidc_github_iam_role" {
"arn:aws:iam::aws:policy/AmazonDynamoDBFullAccess"
]

repo_owners = [
"my-owner"
]

sub = [
"repo:my-owner/my-repo:ref:refs/heads/*"
]

tags = {
Project = "my-project"
Service = "my-service"
Expand Down
24 changes: 19 additions & 5 deletions github-oidc-iam-role/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,27 @@ data "aws_iam_policy_document" "assume_role_policy" {
condition {
test = "StringEquals"
variable = "token.actions.githubusercontent.com:aud"
values = ["sts.amazonaws.com"]
values = ["sts.amazonaws.com"]
}

condition {
test = "StringLike"
variable = "token.actions.githubusercontent.com:sub"
values = ["repo:${var.sub}"]
dynamic "condition" {
for_each = length(var.repo_owners) > 0 ? [1] : []

content {
test = "StringEquals"
variable = "token.actions.githubusercontent.com:repository_owner"
values = var.repo_owners
}
}

dynamic "condition" {
for_each = length(var.sub) > 0 ? [1] : []

content {
test = "StringLike"
variable = "token.actions.githubusercontent.com:sub"
values = var.sub
}
}
}
}
9 changes: 8 additions & 1 deletion github-oidc-iam-role/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ variable "policy_arns" {
default = []
}

variable "repo_owners" {
type = set(string)
description = "Set of repo owners for the assume role policy"
default = []
}

variable "sub" {
type = string
type = set(string)
description = "The sub pattern for the assume role policy (e.g. org/repo:ref:refs/heads/master)"
default = []
}

variable "tags" {
Expand Down
Loading