-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcurrent.tf
49 lines (40 loc) · 1.32 KB
/
current.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
37
38
39
40
41
42
43
44
45
46
47
48
49
locals {
oidc_provider = tobool(var.create_oidc_provider) ? aws_iam_openid_connect_provider.provider[0] : data.aws_iam_openid_connect_provider.provider[0]
projects = flatten([
for repo in var.projects : [
for workspace in repo.workspaces : {
workspace = workspace
project = repo.project
run_phase = repo.run_phase
}
]
])
}
data "aws_partition" "current" {}
data "aws_iam_policy_document" "assume_role" {
statement {
actions = ["sts:AssumeRoleWithWebIdentity"]
effect = "Allow"
condition {
test = "StringEquals"
values = [format("%s", one(local.oidc_provider.client_id_list))]
variable = format("%s:aud", var.url)
}
condition {
test = "ForAnyValue:StringLike"
values = [for org in local.projects : format("organization:%s:project:%s:workspace:%s:run_phase:%s", var.organisation, org.project, org.workspace, org.run_phase)]
variable = format("%s:sub", var.url)
}
principals {
identifiers = [local.oidc_provider.arn]
type = "Federated"
}
}
}
data "aws_iam_openid_connect_provider" "provider" {
count = tobool(var.enabled) && !tobool(var.create_oidc_provider) ? 1 : 0
url = format("https://%s", var.url)
}
data "tls_certificate" "provider" {
url = format("https://%s", var.url)
}