-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
36 lines (27 loc) · 1.45 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
resource "aws_iam_openid_connect_provider" "tfc_provider" {
count = var.create_tfc_oidc_provider ? 1 : 0
url = local.oidc_provider_url
client_id_list = var.tfc_oidc_provider_audiences
thumbprint_list = [
data.tls_certificate.tfc_certificate.certificates[0].sha1_fingerprint,
]
}
module "tfc_workload_identity_role" {
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc"
version = "~> 5.27"
# Role must not be created if no workspaces are listed. Otherwise, anyone on TFC with the right
# audience can assume this role.
create_role = var.create_tfc_workload_identity_role && (
length(local.tfc_workload_identity_workspaces) > 0
)
role_name = var.tfc_workload_identity_role
role_description = var.tfc_workload_identity_role_description
role_policy_arns = var.tfc_workload_identity_role_policy_arns
role_permissions_boundary_arn = var.tfc_workload_identity_role_permissions_boundary_arn
force_detach_policies = true
max_session_duration = var.tfc_workload_identity_role_max_session_duration
provider_url = var.create_tfc_oidc_provider ? aws_iam_openid_connect_provider.tfc_provider[0].url : local.oidc_provider_url
oidc_subjects_with_wildcards = local.tfc_workload_identity_workspaces
oidc_fully_qualified_audiences = try(coalescelist(var.tfc_workload_identity_role_audiences, aws_iam_openid_connect_provider.tfc_provider[0].client_id_list), [])
tags = var.tags
}