Skip to content

Commit 0c66b8f

Browse files
committed
align IAM policies with latest changes for AWS CCM and autoscaler
1 parent 9c46add commit 0c66b8f

File tree

3 files changed

+28
-29
lines changed

3 files changed

+28
-29
lines changed

data.tf

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ data "aws_iam_policy_document" "aws_required" {
8080
}
8181
}
8282

83-
# Required IAM Policy for AWS CCM
83+
# Required IAM policy for AWS CCM (https://cloud-provider-aws.sigs.k8s.io/prerequisites/#iam-policies)
8484
data "aws_iam_policy_document" "aws_ccm" {
8585
count = var.iam_instance_profile == "" && var.enable_ccm ? 1 : 0
8686

@@ -91,13 +91,13 @@ data "aws_iam_policy_document" "aws_ccm" {
9191
"autoscaling:DescribeAutoScalingGroups",
9292
"autoscaling:DescribeLaunchConfigurations",
9393
"autoscaling:DescribeTags",
94-
"autoscaling:DescribeAutoScalingInstances",
9594
"ec2:DescribeInstances",
9695
"ec2:DescribeRegions",
9796
"ec2:DescribeRouteTables",
9897
"ec2:DescribeSecurityGroups",
9998
"ec2:DescribeSubnets",
10099
"ec2:DescribeVolumes",
100+
"ec2:DescribeAvailabilityZones",
101101
"ec2:CreateSecurityGroup",
102102
"ec2:CreateTags",
103103
"ec2:CreateVolume",
@@ -112,6 +112,7 @@ data "aws_iam_policy_document" "aws_ccm" {
112112
"ec2:DetachVolume",
113113
"ec2:RevokeSecurityGroupIngress",
114114
"ec2:DescribeVpcs",
115+
"ec2:DescribeInstanceTopology",
115116
"elasticloadbalancing:AddTags",
116117
"elasticloadbalancing:AttachLoadBalancerToSubnets",
117118
"elasticloadbalancing:ApplySecurityGroupsToLoadBalancer",
@@ -148,6 +149,8 @@ data "aws_iam_policy_document" "aws_ccm" {
148149
}
149150
}
150151

152+
# Required IAM policy for AWS Cluster Autoscaler
153+
# (https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/README.md#full-cluster-autoscaler-features-policy-recommended)
151154
data "aws_iam_policy_document" "aws_autoscaler" {
152155
count = var.enable_autoscaler ? 1 : 0
153156

@@ -157,9 +160,11 @@ data "aws_iam_policy_document" "aws_autoscaler" {
157160
"autoscaling:DescribeAutoScalingInstances",
158161
"autoscaling:DescribeLaunchConfigurations",
159162
"autoscaling:DescribeScalingActivities",
160-
"autoscaling:DescribeTags",
163+
"ec2:DescribeImages",
161164
"ec2:DescribeInstanceTypes",
162-
"ec2:DescribeLaunchTemplateVersions"
165+
"ec2:DescribeLaunchTemplateVersions",
166+
"ec2:GetInstanceTypesFromInstanceRequirements",
167+
"eks:DescribeNodegroup"
163168
]
164169
effect = "Allow"
165170
resources = ["*"]
@@ -168,10 +173,7 @@ data "aws_iam_policy_document" "aws_autoscaler" {
168173
statement {
169174
actions = [
170175
"autoscaling:SetDesiredCapacity",
171-
"autoscaling:TerminateInstanceInAutoScalingGroup",
172-
"ec2:DescribeImages",
173-
"ec2:GetInstanceTypesFromInstanceRequirements",
174-
"eks:DescribeNodegroup"
176+
"autoscaling:TerminateInstanceInAutoScalingGroup"
175177
]
176178
effect = "Allow"
177179
resources = ["*"]

examples/cloud-enabled/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ helm install aws-cloud-controller-manager aws-cloud-controller-manager/aws-cloud
2525

2626
## `cluster-autoscaler`
2727

28-
Match region to your actual region, but it is `us-gov-west-1` in this example.
28+
Match region to your actual region, but it is `us-east-2` in this example. The cluster name also includes a UID suffix that will be created by Terraform at apply time, so change that to yours as well. The version here is coupled to the Kubernetes version. You can run `helm search repo -l autoscaler/cluster-autoscaler` to see all charts and the corresponding app version. Here, we grab the chart version that matches app version 1.33.0 because we are using `rke2` 1.33.
2929

3030
```sh
3131
helm repo add autoscaler https://kubernetes.github.io/autoscaler
3232
helm repo update
3333
helm install autoscaler autoscaler/cluster-autoscaler \
3434
--namespace kube-system \
35-
--set autoDiscovery.clusterName=cloud-enabled-zjl \
36-
--set awsRegion=us-gov-west-1
35+
--version 9.51.0 \
36+
--set autoDiscovery.clusterName=cloud-enabled-dyh \
37+
--set awsRegion=us-east-2
3738
```

modules/agent-nodepool/data.tf

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Required IAM Policy for AWS CCM
1+
# Required IAM policy for AWS CCM (https://cloud-provider-aws.sigs.k8s.io/prerequisites/#iam-policies)
22
data "aws_iam_policy_document" "aws_ccm" {
33
count = var.iam_instance_profile == "" && var.enable_ccm ? 1 : 0
44

@@ -14,42 +14,38 @@ data "aws_iam_policy_document" "aws_ccm" {
1414
"ecr:GetRepositoryPolicy",
1515
"ecr:DescribeRepositories",
1616
"ecr:ListImages",
17-
"ecr:BatchGetImage",
18-
"autoscaling:DescribeTags",
19-
"autoscaling:DescribeAutoScalingGroups",
20-
"autoscaling:DescribeLaunchConfigurations",
21-
"autoscaling:DescribeTags",
17+
"ecr:BatchGetImage"
2218
]
2319
}
2420
}
2521

26-
# Required IAM Policy for AWS Cluster Autoscaler
22+
# Required IAM policy for AWS Cluster Autoscaler
23+
# (https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/README.md#full-cluster-autoscaler-features-policy-recommended)
2724
data "aws_iam_policy_document" "aws_autoscaler" {
28-
count = var.iam_instance_profile == "" && var.enable_autoscaler ? 1 : 0
25+
count = var.enable_autoscaler ? 1 : 0
2926

3027
statement {
31-
effect = "Allow"
32-
resources = ["*"]
3328
actions = [
3429
"autoscaling:DescribeAutoScalingGroups",
3530
"autoscaling:DescribeAutoScalingInstances",
3631
"autoscaling:DescribeLaunchConfigurations",
3732
"autoscaling:DescribeScalingActivities",
38-
"autoscaling:DescribeTags",
33+
"ec2:DescribeImages",
3934
"ec2:DescribeInstanceTypes",
40-
"ec2:DescribeLaunchTemplateVersions"
35+
"ec2:DescribeLaunchTemplateVersions",
36+
"ec2:GetInstanceTypesFromInstanceRequirements",
37+
"eks:DescribeNodegroup"
4138
]
39+
effect = "Allow"
40+
resources = ["*"]
4241
}
4342

4443
statement {
45-
effect = "Allow"
46-
resources = ["*"]
4744
actions = [
4845
"autoscaling:SetDesiredCapacity",
49-
"autoscaling:TerminateInstanceInAutoScalingGroup",
50-
"ec2:DescribeImages",
51-
"ec2:GetInstanceTypesFromInstanceRequirements",
52-
"eks:DescribeNodegroup"
46+
"autoscaling:TerminateInstanceInAutoScalingGroup"
5347
]
48+
effect = "Allow"
49+
resources = ["*"]
5450
}
5551
}

0 commit comments

Comments
 (0)