-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathdata.tf
More file actions
56 lines (45 loc) · 1.45 KB
/
data.tf
File metadata and controls
56 lines (45 loc) · 1.45 KB
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
50
51
52
53
54
55
56
// SPDX-FileCopyrightText: 2024 Daniel Morris <daniel@honestempire.com>
// SPDX-License-Identifier: MIT
data "aws_partition" "this" {
count = var.create ? 1 : 0
}
data "aws_iam_policy_document" "assume_role" {
count = var.create && local.has_github_subjects ? 1 : 0
version = "2012-10-17"
statement {
actions = ["sts:AssumeRoleWithWebIdentity"]
effect = "Allow"
condition {
test = "StringLike"
values = [
for subject in var.github_subjects :
format(
"repo:%s%s",
subject,
length(regexall(":+", subject)) > 0 ? "" : local.default_subject_suffix,
)
]
variable = "${local.oidc_issuer}:sub"
}
condition {
test = "StringEquals"
values = var.additional_audiences != null ? concat(
[format("sts.%s", data.aws_partition.this[0].dns_suffix)],
var.additional_audiences,
) : [format("sts.%s", data.aws_partition.this[0].dns_suffix)]
variable = "${local.oidc_issuer}:aud"
}
principals {
identifiers = [local.oidc_provider_arn]
type = "Federated"
}
}
}
data "aws_iam_openid_connect_provider" "github" {
count = !local.create_oidc_provider ? 1 : 0
url = format("https://token.actions.githubusercontent.com%s", local.enterprise_slug_path)
}
data "tls_certificate" "github" {
count = local.create_oidc_provider ? 1 : 0
url = "https://token.actions.githubusercontent.com/.well-known/openid-configuration"
}