Skip to content

Instantly share code, notes, and snippets.

@arashkaffamanesh
Last active August 16, 2020 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arashkaffamanesh/d22d578bbe2a1518f733051856718d6a to your computer and use it in GitHub Desktop.
Save arashkaffamanesh/d22d578bbe2a1518f733051856718d6a to your computer and use it in GitHub Desktop.
# taken and adapted from here to get it working:
# https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/autoscaling.md
resource "aws_iam_role_policy_attachment" "workers_autoscaling" {
policy_arn = aws_iam_policy.worker_autoscaling.arn
role = module.eks.worker_iam_role_name
}
resource "aws_iam_policy" "worker_autoscaling" {
name_prefix = "ClusterAutoScalingPolicy-${var.cluster_name}"
description = "EKS worker node autoscaling policy for cluster ${var.cluster_name}"
policy = data.aws_iam_policy_document.worker_autoscaling.json
path = var.iam_path
}
data "aws_iam_policy_document" "worker_autoscaling" {
statement {
sid = "eksWorkerAutoscalingAll"
effect = "Allow"
actions = [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeLaunchConfigurations",
"autoscaling:DescribeTags",
"ec2:DescribeLaunchTemplateVersions",
"autoscaling:SetDesiredCapacity",
"autoscaling:TerminateInstanceInAutoScalingGroup",
"autoscaling:UpdateAutoScalingGroup",
]
resources = ["*"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment