-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.tf
55 lines (47 loc) · 1.29 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
####################
## OpenID Connect ##
####################
data "tls_certificate" "main" {
url = data.terraform_remote_state.eks_cluster.outputs.eks_oidc
}
resource "aws_iam_openid_connect_provider" "main" {
url = data.terraform_remote_state.eks_cluster.outputs.eks_oidc
client_id_list = [
"sts.amazonaws.com",
]
thumbprint_list = [
data.tls_certificate.main.certificates.0.sha1_fingerprint
]
}
################
## IAM Policy ##
################
resource "aws_iam_policy" "main" {
name = var.policy_name
path = "/"
description = "Allow AWS EKS PODs to get a specify S3 Object"
policy = file("${path.module}/policies/s3_policy.json")
}
resource "aws_iam_role" "main" {
name = var.role_name
path = "/"
assume_role_policy = data.template_file.role_trust_relationship.rendered
force_detach_policies = false
}
resource "aws_iam_role_policy_attachment" "main" {
role = aws_iam_role.main.name
policy_arn = aws_iam_policy.main.arn
}
############
## K8s SA ##
############
resource "kubernetes_service_account" "main" {
metadata {
name = var.role_name
namespace = "matheus"
annotations = {
"eks.amazonaws.com/role-arn" = aws_iam_role.main.arn
}
}
automount_service_account_token = true
}