Skip to content

Commit 3728299

Browse files
author
Anders Åslund
committed
Add optional iam_path
1 parent 87114b0 commit 3728299

File tree

6 files changed

+17
-0
lines changed

6 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ project adheres to [Semantic Versioning](http://semver.org/).
1919

2020
# History
2121

22+
## [[v2.2.2](https://github.com/terraform-aws-modules/terraform-aws-eks/compare/v2.2.1...v2.2.2)] - 2019-02-25]
23+
24+
### Added
25+
26+
- Ability to specify a path for IAM roles (by @tekn0ir)
27+
2228
## [[v2.2.1](https://github.com/terraform-aws-modules/terraform-aws-eks/compare/v2.2.0...v2.2.1)] - 2019-02-18]
2329

2430
### Added

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a
148148
| workers\_group\_launch\_template\_defaults | Override default values for target groups. See workers_group_defaults_defaults in locals.tf for valid keys. | map | `{}` | no |
149149
| write\_aws\_auth\_config | Whether to write the aws-auth configmap file. | string | `"true"` | no |
150150
| write\_kubeconfig | Whether to write a Kubectl config file containing the cluster configuration. Saved to `config_output_path`. | string | `"true"` | no |
151+
| iam\_path | If provided, all IAM roles will be created with path. | string | `"/"` | no |
151152
152153
## Outputs
153154

cluster.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ resource "aws_iam_role" "cluster" {
5353
name_prefix = "${var.cluster_name}"
5454
assume_role_policy = "${data.aws_iam_policy_document.cluster_assume_role_policy.json}"
5555
permissions_boundary = "${var.permissions_boundary}"
56+
path = "${var.iam_path}"
5657
force_detach_policies = true
5758
}
5859

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,8 @@ variable "permissions_boundary" {
221221
description = "If provided, all IAM roles will be created with this permissions boundary attached."
222222
default = ""
223223
}
224+
225+
variable "iam_path" {
226+
description = "If provided, all IAM roles will be created on this path."
227+
default = "/"
228+
}

workers.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,15 @@ resource "aws_iam_role" "workers" {
115115
name_prefix = "${aws_eks_cluster.this.name}"
116116
assume_role_policy = "${data.aws_iam_policy_document.workers_assume_role_policy.json}"
117117
permissions_boundary = "${var.permissions_boundary}"
118+
path = "${var.iam_path}"
118119
force_detach_policies = true
119120
}
120121

121122
resource "aws_iam_instance_profile" "workers" {
122123
name_prefix = "${aws_eks_cluster.this.name}"
123124
role = "${lookup(var.worker_groups[count.index], "iam_role_id", lookup(local.workers_group_defaults, "iam_role_id"))}"
124125
count = "${var.worker_group_count}"
126+
path = "${var.iam_path}"
125127
}
126128

127129
resource "aws_iam_role_policy_attachment" "workers_AmazonEKSWorkerNodePolicy" {
@@ -158,6 +160,7 @@ resource "aws_iam_policy" "worker_autoscaling" {
158160
name_prefix = "eks-worker-autoscaling-${aws_eks_cluster.this.name}"
159161
description = "EKS worker node autoscaling policy for cluster ${aws_eks_cluster.this.name}"
160162
policy = "${data.aws_iam_policy_document.worker_autoscaling.json}"
163+
path = "${var.iam_path}"
161164
}
162165

163166
data "aws_iam_policy_document" "worker_autoscaling" {

workers_launch_template.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,5 @@ resource "aws_iam_instance_profile" "workers_launch_template" {
105105
name_prefix = "${aws_eks_cluster.this.name}"
106106
role = "${lookup(var.worker_groups_launch_template[count.index], "iam_role_id", lookup(local.workers_group_launch_template_defaults, "iam_role_id"))}"
107107
count = "${var.worker_group_launch_template_count}"
108+
path = "${var.iam_path}"
108109
}

0 commit comments

Comments
 (0)