Skip to content

Commit 2f1b2bf

Browse files
authored
feat: Update cluster autoscaler policy for recent permission changes upstream (#255)
1 parent be6303e commit 2f1b2bf

File tree

3 files changed

+18
-31
lines changed

3 files changed

+18
-31
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.71.0
3+
rev: v1.72.1
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_validate

README.md

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
```hcl
1515
module "iam_account" {
1616
source = "terraform-aws-modules/iam/aws//modules/iam-account"
17-
version = "~> 4"
1817
1918
account_alias = "awesome-company"
2019
@@ -28,7 +27,6 @@ module "iam_account" {
2827
```hcl
2928
module "iam_assumable_role" {
3029
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-role"
31-
version = "~> 4"
3230
3331
trusted_role_arns = [
3432
"arn:aws:iam::307990089504:root",
@@ -53,7 +51,6 @@ module "iam_assumable_role" {
5351
```hcl
5452
module "iam_assumable_role_with_oidc" {
5553
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc"
56-
version = "~> 4"
5754
5855
create_role = true
5956
@@ -77,7 +74,6 @@ module "iam_assumable_role_with_oidc" {
7774
```hcl
7875
module "iam_assumable_role_with_saml" {
7976
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-saml"
80-
version = "~> 4"
8177
8278
create_role = true
8379
@@ -101,7 +97,6 @@ module "iam_assumable_role_with_saml" {
10197
```hcl
10298
module "iam_assumable_roles" {
10399
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-roles"
104-
version = "~> 4"
105100
106101
trusted_role_arns = [
107102
"arn:aws:iam::307990089504:root",
@@ -123,7 +118,6 @@ module "iam_assumable_roles" {
123118
```hcl
124119
module "iam_assumable_roles_with_saml" {
125120
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-roles-with-saml"
126-
version = "~> 4"
127121
128122
create_admin_role = true
129123
@@ -141,7 +135,6 @@ module "iam_assumable_roles_with_saml" {
141135
```hcl
142136
module "iam_eks_role" {
143137
source = "terraform-aws-modules/iam/aws//modules/iam-eks-role"
144-
version = "~> 4"
145138
146139
role_name = "my-app"
147140
@@ -157,9 +150,9 @@ module "iam_eks_role" {
157150
Name = "eks-role"
158151
}
159152
160-
role_policy_arns = [
161-
"arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy",
162-
]
153+
role_policy_arns = {
154+
AmazonEKS_CNI_Policy = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
155+
}
163156
}
164157
```
165158

@@ -168,7 +161,6 @@ module "iam_eks_role" {
168161
```hcl
169162
module "iam_group_with_assumable_roles_policy" {
170163
source = "terraform-aws-modules/iam/aws//modules/iam-group-with-assumable-roles-policy"
171-
version = "~> 4"
172164
173165
name = "production-readonly"
174166
@@ -188,7 +180,6 @@ module "iam_group_with_assumable_roles_policy" {
188180
```hcl
189181
module "iam_group_with_policies" {
190182
source = "terraform-aws-modules/iam/aws//modules/iam-group-with-policies"
191-
version = "~> 4"
192183
193184
name = "superadmins"
194185
@@ -217,7 +208,6 @@ module "iam_group_with_policies" {
217208
```hcl
218209
module "iam_policy" {
219210
source = "terraform-aws-modules/iam/aws//modules/iam-policy"
220-
version = "~> 4"
221211
222212
name = "example"
223213
path = "/"
@@ -245,7 +235,6 @@ EOF
245235
```hcl
246236
module "iam_read_only_policy" {
247237
source = "terraform-aws-modules/iam/aws//modules/iam-read-only-policy"
248-
version = "~> 4"
249238
250239
name = "example"
251240
path = "/"
@@ -260,7 +249,6 @@ module "iam_read_only_policy" {
260249
```hcl
261250
module "vpc_cni_irsa" {
262251
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
263-
version = "~> 4"
264252
265253
role_name = "vpc-cni"
266254
@@ -270,7 +258,7 @@ module "vpc_cni_irsa" {
270258
oidc_providers = {
271259
main = {
272260
provider_arn = "arn:aws:iam::012345678901:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/5C54DDF35ER19312844C7333374CC09D"
273-
namespace_service_accounts = ["default:my-app", "canary:my-app"]
261+
namespace_service_accounts = ["kube-system:aws-node"]
274262
}
275263
}
276264
@@ -285,7 +273,6 @@ module "vpc_cni_irsa" {
285273
```hcl
286274
module "iam_user" {
287275
source = "terraform-aws-modules/iam/aws//modules/iam-user"
288-
version = "~> 4"
289276
290277
name = "vasya.pupkin"
291278
force_destroy = true
@@ -300,50 +287,48 @@ module "iam_user" {
300287

301288
AWS published [IAM Best Practices](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html) and this Terraform module was created to help with some of points listed there:
302289

303-
### 1. Create Individual IAM Users
290+
1. Create Individual IAM Users
304291

305292
Use [iam-user module](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-user) module to manage IAM users.
306293

307-
### 2. Use AWS Defined Policies to Assign Permissions Whenever Possible
294+
2. Use AWS Defined Policies to Assign Permissions Whenever Possible
308295

309296
Use [iam-assumable-roles module](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-assumable-roles) to create IAM roles with managed policies to support common tasks (admin, poweruser or readonly).
310297

311-
### 3. Use Groups to Assign Permissions to IAM Users
298+
3. Use Groups to Assign Permissions to IAM Users
312299

313300
Use [iam-group-with-assumable-roles-policy module](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-group-with-assumable-roles-policy) to manage IAM groups of users who can assume roles.
314-
315301
Use [iam-group-with-policies module](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-group-with-policies) to manage IAM groups of users where specified IAM policies are allowed.
316302

317-
### 4. Configure a Strong Password Policy for Your Users
303+
4. Configure a Strong Password Policy for Your Users
318304

319305
Use [iam-account module](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-account) to set password policy for your IAM users.
320306

321-
### 5. Enable MFA for Privileged Users
307+
5. Enable MFA for Privileged Users
322308

323-
Terraform can't configure MFA for the user. It is only possible via [AWS Console](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa.html) and [AWS CLI](https://docs.aws.amazon.com/cli/latest/reference/iam/enable-mfa-device.html).
309+
Use [iam-assumable-roles module](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-assumable-roles) to create IAM roles that require MFA.
324310

325-
### 6. Delegate by Using Roles Instead of by Sharing Credentials
311+
6. Delegate by Using Roles Instead of by Sharing Credentials
326312

327313
[iam-assumable-role](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-assumable-role), [iam-assumable-roles](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-assumable-roles), [iam-assumable-roles-with-saml](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-assumable-roles-with-saml) and [iam-group-with-assumable-roles-policy](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-group-with-assumable-roles-policy) modules provide complete set of functionality required for this.
328314

329-
### 7. Use Policy Conditions for Extra Security
315+
7. Use Policy Conditions for Extra Security
330316

331317
[iam-assumable-roles module](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-assumable-roles) can be configured to require valid MFA token when different roles are assumed (for example, admin role requires MFA, but readonly - does not).
332318

333-
### 8. Create IAM Policies
319+
8. Create IAM Policies
334320

335321
Use [iam-policy module](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-policy) module to manage IAM policy.
336-
337322
Use [iam-read-only-policy module](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/modules/iam-read-only-policy) module to manage IAM read-only policies.
338323

339324
## Examples
340325

341326
- [iam-account](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-account) - Set AWS account alias and password policy
342-
- [iam-assumable-role](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-assumable-role) - Create individual IAM role which can be assumed from specified ARNs (AWS accounts, IAM users, etc)
343327
- [iam-assumable-role-with-oidc](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-assumable-role-with-oidc) - Create individual IAM role which can be assumed from specified subjects federated with a OIDC Identity Provider
344328
- [iam-assumable-role-with-saml](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-assumable-role-with-saml) - Create individual IAM role which can be assumed by users with a SAML Identity Provider
345-
- [iam-assumable-roles](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-assumable-roles) - Create several IAM roles which can be assumed from specified ARNs (AWS accounts, IAM users, etc)
329+
- [iam-assumable-role](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-assumable-role) - Create individual IAM role which can be assumed from specified ARNs (AWS accounts, IAM users, etc)
346330
- [iam-assumable-roles-with-saml](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-assumable-roles-with-saml) - Create several IAM roles which can be assumed by users with a SAML Identity Provider
331+
- [iam-assumable-roles](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-assumable-roles) - Create several IAM roles which can be assumed from specified ARNs (AWS accounts, IAM users, etc)
347332
- [iam-eks-role](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-eks-role) - Create an IAM role that can be assumed by one or more EKS `ServiceAccount`
348333
- [iam-group-complete](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-group-complete) - IAM group with users who are allowed to assume IAM roles in another AWS account and have access to specified IAM policies
349334
- [iam-group-with-assumable-roles-policy](https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-group-with-assumable-roles-policy) - IAM group with users who are allowed to assume IAM roles in the same or in separate AWS account

modules/iam-role-for-service-accounts-eks/policies.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ data "aws_iam_policy_document" "cluster_autoscaler" {
6666
"autoscaling:DescribeAutoScalingGroups",
6767
"autoscaling:DescribeAutoScalingInstances",
6868
"autoscaling:DescribeLaunchConfigurations",
69+
"autoscaling:DescribeScalingActivities",
6970
"autoscaling:DescribeTags",
7071
"ec2:DescribeLaunchTemplateVersions",
7172
"ec2:DescribeInstanceTypes",
73+
"eks:DescribeNodegroup",
7274
]
7375

7476
resources = ["*"]

0 commit comments

Comments
 (0)