Skip to content

Commit

Permalink
fix: Discard the order of thumbprints
Browse files Browse the repository at this point in the history
Discards the order of thumbprints and adds the known thumbprints so that
CI workflows that apply the OIDC module frequently don't blow up.
  • Loading branch information
unfunco committed Jun 29, 2023
1 parent f3abd4e commit 5fae63a
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@
// limitations under the License.

locals {
github_organizations = toset([for repo in var.github_repositories : split("/", repo)[0]])
oidc_provider_arn = var.enabled ? (var.create_oidc_provider ? aws_iam_openid_connect_provider.github[0].arn : data.aws_iam_openid_connect_provider.github[0].arn) : ""
partition = data.aws_partition.current.partition
github_organizations = toset([
for repo in var.github_repositories : split("/", repo)[0]
])
known_thumbprints = [
"1c58a3a8518e8759bf075b76b750d4f2df264fcd",
"6938fd4d98bab03faadb97b34396831e3780aea1",
]
oidc_provider_arn = var.enabled ? (var.create_oidc_provider ? aws_iam_openid_connect_provider.github[0].arn : data.aws_iam_openid_connect_provider.github[0].arn) : ""
partition = data.aws_partition.current.partition
}

resource "aws_iam_role" "github" {
Expand Down Expand Up @@ -71,10 +77,16 @@ resource "aws_iam_openid_connect_provider" "github" {

tags = var.tags
url = "https://token.actions.githubusercontent.com%{if var.enterprise_slug != ""}/${var.enterprise_slug}%{endif}"
thumbprint_list = var.additional_thumbprints != null ? distinct(
thumbprint_list = var.additional_thumbprints != null ? toset(
concat(
local.known_thumbprints,
[data.tls_certificate.github.certificates[0].sha1_fingerprint],
[for thumbprint in var.additional_thumbprints : thumbprint]
[for thumbprint in var.additional_thumbprints : thumbprint],
)
) : [data.tls_certificate.github.certificates[0].sha1_fingerprint]
) : toset(
concat(
local.known_thumbprints,
[data.tls_certificate.github.certificates[0].sha1_fingerprint],
)
)
}

0 comments on commit 5fae63a

Please sign in to comment.