-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaws-github-oidc.tf
More file actions
71 lines (63 loc) · 1.6 KB
/
Copy pathaws-github-oidc.tf
File metadata and controls
71 lines (63 loc) · 1.6 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
resource "aws_iam_openid_connect_provider" "github_actions" {
url = "https://token.actions.githubusercontent.com"
client_id_list = [
"sts.amazonaws.com"
]
thumbprint_list = [
"6938fd4d98bab03faadb97b34396831e3780aea1"
]
tags = {
ManagedBy = "Terraform"
}
}
resource "aws_iam_role" "github_actions_sops_kms" {
name = "github-actions-sops-kms"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Principal = {
Federated = aws_iam_openid_connect_provider.github_actions.arn
}
Action = "sts:AssumeRoleWithWebIdentity"
Condition = {
StringEquals = {
"token.actions.githubusercontent.com:aud" = "sts.amazonaws.com"
}
StringLike = {
"token.actions.githubusercontent.com:sub" = [
"repo:makeitworkcloud/tfroot-aws:*",
"repo:makeitworkcloud/tfroot-cloudflare:*",
"repo:makeitworkcloud/tfroot-github:*",
"repo:makeitworkcloud/tfroot-libvirt:*"
]
}
}
}
]
})
tags = {
ManagedBy = "Terraform"
}
}
resource "aws_iam_role_policy" "github_actions_sops_kms" {
name = "sops-kms"
role = aws_iam_role.github_actions_sops_kms.id
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = [
"kms:Decrypt",
"kms:DescribeKey",
"kms:Encrypt",
"kms:GenerateDataKey*",
"kms:ReEncrypt*"
]
Resource = aws_kms_key.sops.arn
}
]
})
}