-
Notifications
You must be signed in to change notification settings - Fork 0
/
aim.tf
65 lines (62 loc) · 2.09 KB
/
aim.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
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
resource "aws_iam_policy" "clusternode" {
name = "${var.name}-cluster-node-policy"
description = "Needed by EC2 worker instances to create EBS volumes used by GS DIH"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Sid = "PVolumeCreate"
Action = [
"ec2:CreateVolume",
"ec2:DeleteVolume",
"ec2:CreateSnapshot",
"ec2:DeleteSnapshot",
"ec2:AttachVolume",
"ec2:DetachVolume",
"ec2:ModifyVolume",
"ec2:DescribeAvailabilityZones",
"ec2:DescribeInstances",
"ec2:DescribeSnapshots",
"ec2:DescribeTags",
"ec2:DescribeVolumes",
"ec2:DescribeVolumesModifications",
"ec2:CreateTags",
"ec2:DeleteTags",
"ec2:DescribeLaunchTemplateVersions",
"ec2:DescribeInstanceTypes",
]
Effect = "Allow"
Resource = [
"arn:aws:ec2:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:*",
]
},
{
Sid = "Autoscaler"
Action = [
"cloudwatch:GetMetricData",
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup",
"autoscaling:UpdateAutoScalingGroup",
"autoscaling:BatchPutScheduledUpdateGroupAction",
"autoscaling:BatchDeleteScheduledAction",
"autoscaling:PutScalingPolicy",
"autoscaling:DeletePolicy",
"eks:DescribeNodegroup",
]
Effect = "Allow"
Resource = [
"arn:aws:autoscaling:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:autoScalingGroup:*:autoScalingGroupName/*",
"arn:aws:eks:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:nodegroup/${local.cluster_name}/*",
]
},
{
Sid = "AutoscalerDescribe"
Action = ["autoscaling:Describe*"]
Effect = "Allow"
Resource = ["*"]
}
]
})
}