-
Notifications
You must be signed in to change notification settings - Fork 1
/
iam_policies.tf
41 lines (39 loc) · 1.32 KB
/
iam_policies.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
resource "aws_iam_policy" "autoscaler_modify_asg" {
name = "ClusterAutoscalerPolicy-${var.environment}"
count = var.enable_cluster_autoscaler == true ? 1 : 0
description = "Policy created to allow the Cluster autoscaler service to access the underlying AWS ASG"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeLaunchConfigurations",
"autoscaling:DescribeTags",
"ec2:DescribeInstanceTypes",
"ec2:DescribeLaunchTemplateVersions",
"ec2:GetInstanceTypesFromInstanceRequirements",
"eks:DescribeNodegroup"
]
Effect = "Allow"
Resource = "*"
},
{
Action = [
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup",
"autoscaling:UpdateAutoScalingGroup",
]
Effect = "Allow"
Resource = "*"
Condition = {
"StringEquals" = {
"autoscaling:ResourceTag/k8s.io/cluster-autoscaler/${local.cluster_name}" = ["owned"],
"autoscaling:ResourceTag/k8s.io/cluster-autoscaler/enabled" = ["true"]
}
}
}
]
})
}