forked from marcincuber/eks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.tf
132 lines (109 loc) · 2.93 KB
/
data.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
data "aws_caller_identity" "current" {}
data "aws_partition" "current" {}
data "aws_region" "current" {}
# Fetch latest ami_id for specified ${var.eks_version}
data "aws_ssm_parameter" "eks_optimized_ami_id" {
name = "/aws/service/eks/optimized-ami/${var.eks_version}/amazon-linux-2/recommended/image_id"
with_decryption = true
}
data "aws_ssm_parameter" "eks_al2023" {
name = "/aws/service/eks/optimized-ami/${var.eks_version}/amazon-linux-2023/x86_64/standard/recommended/image_id"
with_decryption = true
}
data "tls_certificate" "cluster" {
url = aws_eks_cluster.cluster.identity[0].oidc[0].issuer
}
data "aws_iam_policy_document" "cluster_role_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["eks.${data.aws_partition.current.dns_suffix}"]
}
}
}
data "aws_iam_policy_document" "eks_node_group_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.${data.aws_partition.current.dns_suffix}"]
}
}
}
data "aws_iam_policy_document" "eks_node_karpenter_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.${data.aws_partition.current.dns_suffix}"]
}
}
}
data "aws_iam_policy_document" "eks_node_custom_inline_policy" {
statement {
actions = [
"ecr:CreateRepository",
"ecr:ReplicateImage",
"ecr:BatchImportUpstreamImage"
]
resources = ["*"]
}
}
data "aws_iam_policy_document" "kms_policy_cluster" {
statement {
actions = [
"kms:*"
]
resources = ["*"]
principals {
type = "AWS"
identifiers = ["arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:root"]
}
}
statement {
actions = [
"kms:Encrypt*",
"kms:Decrypt*",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:Describe*"
]
resources = ["*"]
principals {
type = "Service"
identifiers = ["logs.${data.aws_region.current.name}.${data.aws_partition.current.dns_suffix}"]
}
}
statement {
actions = [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:CreateGrant",
"kms:DescribeKey",
"kms:RetireGrant"
]
resources = ["*"]
principals {
type = "Service"
identifiers = ["events.${data.aws_partition.current.dns_suffix}"]
}
}
}
data "aws_iam_policy_document" "karpenter_spot_interruption" {
statement {
actions = [
"sqs:SendMessage"
]
resources = [aws_sqs_queue.karpenter_spot_interruption.arn]
principals {
type = "Service"
identifiers = [
"events.${data.aws_partition.current.dns_suffix}",
"sqs.${data.aws_partition.current.dns_suffix}"
]
}
}
}