Skip to content

Commit 0ce5ad6

Browse files
authored
Remove distinction between exact and wildcard subjects (#3)
1 parent b57da80 commit 0ce5ad6

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

data.tf

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
locals {
2-
tfc_workload_identity_workspaces_exact = flatten([
2+
tfc_workload_identity_workspaces = flatten([
33
for org, workspaces in var.tfc_workload_identity_workspaces : [
4-
for workspace in workspaces : [
5-
"organization:${org}:workspace:${workspace}:run_phase:plan",
6-
"organization:${org}:workspace:${workspace}:run_phase:apply",
7-
] if !can(regex("\\*+", workspace))
8-
]
9-
])
10-
tfc_workload_identity_workspaces_wildcard = flatten([
11-
for org, workspaces in var.tfc_workload_identity_workspaces : [
12-
for workspace in workspaces : "organization:${org}:workspace:${workspace}:run_phase:*" if can(regex("\\*+", workspace))
4+
for workspace in workspaces : "organization:${org}:workspace:${workspace}:run_phase:*"
135
]
146
])
157

main.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module "tfc_workload_identity_role" {
1515
# Role must not be created if no workspaces are listed. Otherwise, anyone on TFC with the right
1616
# audience can assume this role.
1717
create_role = var.create_tfc_workload_identity_role && (
18-
length(local.tfc_workload_identity_workspaces_exact) + length(local.tfc_workload_identity_workspaces_wildcard) > 0
18+
length(local.tfc_workload_identity_workspaces) > 0
1919
)
2020

2121
role_name = var.tfc_workload_identity_role
@@ -29,8 +29,7 @@ module "tfc_workload_identity_role" {
2929

3030
provider_url = var.create_tfc_oidc_provider ? aws_iam_openid_connect_provider.tfc_provider[0].url : local.oidc_provider_url
3131

32-
oidc_fully_qualified_subjects = local.tfc_workload_identity_workspaces_exact
33-
oidc_subjects_with_wildcards = local.tfc_workload_identity_workspaces_wildcard
32+
oidc_subjects_with_wildcards = local.tfc_workload_identity_workspaces
3433
oidc_fully_qualified_audiences = try(coalescelist(var.tfc_workload_identity_role_audiences, aws_iam_openid_connect_provider.tfc_provider[0].client_id_list), [])
3534

3635
tags = var.tags

output.tf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,5 @@ output "tfc_workload_identity_audience" {
1010

1111
output "tfc_workload_identity_workspaces" {
1212
description = "Workspaces allowed to assume the Workload Identity IAM Role"
13-
value = concat(
14-
local.tfc_workload_identity_workspaces_exact,
15-
local.tfc_workload_identity_workspaces_wildcard,
16-
)
13+
value = local.tfc_workload_identity_workspaces
1714
}

0 commit comments

Comments
 (0)