Skip to content

Commit 3316c82

Browse files
author
FERNANDEZ Xavier (Canal Plus Prestataire)
committed
feat: allow to specify the managed cluster IAM role name
1 parent f8bdea1 commit 3316c82

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a
240240
| <a name="input_cluster_endpoint_private_access_cidrs"></a> [cluster\_endpoint\_private\_access\_cidrs](#input\_cluster\_endpoint\_private\_access\_cidrs) | List of CIDR blocks which can access the Amazon EKS private API server endpoint. | `list(string)` | `null` | no |
241241
| <a name="input_cluster_endpoint_public_access"></a> [cluster\_endpoint\_public\_access](#input\_cluster\_endpoint\_public\_access) | Indicates whether or not the Amazon EKS public API server endpoint is enabled. | `bool` | `true` | no |
242242
| <a name="input_cluster_endpoint_public_access_cidrs"></a> [cluster\_endpoint\_public\_access\_cidrs](#input\_cluster\_endpoint\_public\_access\_cidrs) | List of CIDR blocks which can access the Amazon EKS public API server endpoint. | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
243-
| <a name="input_cluster_iam_role_name"></a> [cluster\_iam\_role\_name](#input\_cluster\_iam\_role\_name) | IAM role name for the cluster. Only applicable if manage\_cluster\_iam\_resources is set to false. Set this to reuse an existing IAM role. | `string` | `""` | no |
243+
| <a name="input_cluster_iam_role_name"></a> [cluster\_iam\_role\_name](#input\_cluster\_iam\_role\_name) | IAM role name for the cluster. If manage\_cluster\_iam\_resources is set to false, set this to reuse an existing IAM role. If manage\_cluster\_iam\_resources is set to true, set this to force the created role name. | `string` | `""` | no |
244244
| <a name="input_cluster_log_kms_key_id"></a> [cluster\_log\_kms\_key\_id](#input\_cluster\_log\_kms\_key\_id) | If a KMS Key ARN is set, this key will be used to encrypt the corresponding log group. Please be sure that the KMS Key has an appropriate key policy (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/encrypt-log-data-kms.html) | `string` | `""` | no |
245245
| <a name="input_cluster_log_retention_in_days"></a> [cluster\_log\_retention\_in\_days](#input\_cluster\_log\_retention\_in\_days) | Number of days to retain log events. Default retention - 90 days. | `number` | `90` | no |
246246
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the EKS cluster. Also used as a prefix in names of related resources. | `string` | n/a | yes |

cluster.tf

+2-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ resource "aws_security_group_rule" "cluster_https_worker_ingress" {
118118

119119
resource "aws_iam_role" "cluster" {
120120
count = var.manage_cluster_iam_resources && var.create_eks ? 1 : 0
121-
name_prefix = var.cluster_name
121+
name_prefix = var.cluster_iam_role_name != "" ? null : var.cluster_name
122+
name = var.cluster_iam_role_name != "" ? var.cluster_iam_role_name : null
122123
assume_role_policy = data.aws_iam_policy_document.cluster_assume_role_policy.json
123124
permissions_boundary = var.permissions_boundary
124125
path = var.iam_path

variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ variable "manage_cluster_iam_resources" {
290290
}
291291

292292
variable "cluster_iam_role_name" {
293-
description = "IAM role name for the cluster. Only applicable if manage_cluster_iam_resources is set to false. Set this to reuse an existing IAM role."
293+
description = "IAM role name for the cluster. If manage_cluster_iam_resources is set to false, set this to reuse an existing IAM role. If manage_cluster_iam_resources is set to true, set this to force the created role name."
294294
type = string
295295
default = ""
296296
}

0 commit comments

Comments
 (0)