-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheks-roles.tf
More file actions
69 lines (57 loc) · 1.89 KB
/
Copy patheks-roles.tf
File metadata and controls
69 lines (57 loc) · 1.89 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
data "aws_partition" "current" {}
locals {
tags = {
account = var.app.account
project = "infra"
application = "eks"
team = "sre"
}
}
################################################
# IAM ROLE for self managed node groups #
################################################
data "aws_iam_policy_document" "eks_node_group_assume_role_policy" {
statement {
sid = "EKSNodeAssumeRole"
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.${data.aws_partition.current.dns_suffix}"]
}
}
}
resource "aws_iam_role" "eks_node_group_iam_role" {
name = var.node_group_iam_role_name
description = "eks ${var.app.account} self managed node group IAM role"
assume_role_policy = data.aws_iam_policy_document.eks_node_group_assume_role_policy.json
force_detach_policies = true
tags = local.tags
}
resource "aws_iam_instance_profile" "eks_node_group_profile" {
role = aws_iam_role.eks_node_group_iam_role.name
name = var.node_group_iam_role_name
lifecycle {
create_before_destroy = true
}
tags = local.tags
}
################################################
# IAM ROLE for eks cluster #
################################################
data "aws_iam_policy_document" "eks_cluster_assume_role_policy" {
statement {
sid = "EKSClusterAssumeRole"
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["eks.${data.aws_partition.current.dns_suffix}"]
}
}
}
resource "aws_iam_role" "cluster_iam_role" {
name = var.cluster_iam_role_name
description = "eks ${var.app.account} cluster IAM role"
assume_role_policy = data.aws_iam_policy_document.eks_cluster_assume_role_policy.json
force_detach_policies = true
tags = local.tags
}