-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcurrent.tf
41 lines (33 loc) · 996 Bytes
/
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
data "aws_partition" "current" {}
locals {
repositories_branches = flatten([
for repo in var.github_repositories : [
for branch in repo.branches : {
branch = branch
name = repo.name
}
]
])
}
data "aws_iam_policy_document" "assume_role" {
statement {
actions = ["sts:AssumeRoleWithWebIdentity"]
effect = "Allow"
condition {
test = "ForAnyValue:StringLike"
values = [for repo in local.repositories_branches : format("repo:%s/%s:%s", var.github_organisation, repo.name, repo.branch)]
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/.well-known/openid-configuration", var.url)
}