Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add audiences in the OIDC provider configuration #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 10 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
*/
resource "aws_iam_openid_connect_provider" "this" {
count = var.create_oidc_provider ? 1 : 0
client_id_list = [
"sts.amazonaws.com",
]
client_id_list = var.audiences
thumbprint_list = [var.github_thumbprint]
url = "https://token.actions.githubusercontent.com"
}
Expand Down Expand Up @@ -51,6 +49,15 @@ data "aws_iam_policy_document" "this" {
variable = "token.actions.githubusercontent.com:sub"
}

condition {
test = "StringEquals"
values = [
for audience in var.audiences :
"${audience}"
]
variable = "token.actions.githubusercontent.com:aud"
}

principals {
identifiers = [try(aws_iam_openid_connect_provider.this[0].arn, var.oidc_provider_arn)]
type = "Federated"
Expand Down
7 changes: 7 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,10 @@ variable "role_description" {
type = string
default = "Role assumed by the GitHub OIDC provider."
}

variable "audiences" {
description = "(Optional) List of audiences that will be in the JWT the OIDC provider generates"
type = list(string)
default = ["sts.amazonaws.com"]
}

Loading