From 5554294b34fdb42f26555d665fd8375e48426e85 Mon Sep 17 00:00:00 2001 From: ocofaigh Date: Tue, 12 Nov 2024 15:37:34 +0000 Subject: [PATCH] feat: added ability to set wait_til and wait_till_timeout --- README.md | 2 ++ main.tf | 6 +++++- variables.tf | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d6086ec..13fbe103 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,8 @@ You need the following permissions to run this module. | [logs\_agent\_selected\_log\_source\_paths](#input\_logs\_agent\_selected\_log\_source\_paths) | The list of specific log sources paths. Logs will only be collected from the specified log source paths. If no paths are specified, it will send logs from `/var/log/containers`. | `list(string)` | `[]` | no | | [logs\_agent\_tolerations](#input\_logs\_agent\_tolerations) | List of tolerations to apply to Logs agent. The default value means a pod will run on every node. |
list(object({
key = optional(string)
operator = optional(string)
value = optional(string)
effect = optional(string)
tolerationSeconds = optional(number)
}))
|
[
{
"operator": "Exists"
}
]
| no | | [logs\_agent\_trusted\_profile](#input\_logs\_agent\_trusted\_profile) | The IBM Cloud trusted profile ID. Used only when `logs_agent_iam_mode` is set to `TrustedProfile`. The trusted profile must have an IBM Cloud Logs `Sender` role. | `string` | `null` | no | +| [wait\_till](#input\_wait\_till) | To avoid long wait times when you run your Terraform code, you can specify the stage when you want Terraform to mark the cluster resource creation as completed. Depending on what stage you choose, the cluster creation might not be fully completed and continues to run in the background. However, your Terraform code can continue to run without waiting for the cluster to be fully created. Supported args are `MasterNodeReady`, `OneWorkerNodeReady`, `IngressReady` and `Normal` | `string` | `"Normal"` | no | +| [wait\_till\_timeout](#input\_wait\_till\_timeout) | Timeout for wait\_till in minutes. | `number` | `90` | no | ### Outputs diff --git a/main.tf b/main.tf index 155c2d50..1a70f3c7 100644 --- a/main.tf +++ b/main.tf @@ -7,17 +7,21 @@ data "ibm_container_vpc_cluster" "cluster" { count = var.is_vpc_cluster ? 1 : 0 name = var.cluster_id resource_group_id = var.cluster_resource_group_id + wait_till = var.wait_till + wait_till_timeout = var.wait_till_timeout } data "ibm_container_cluster" "cluster" { count = var.is_vpc_cluster ? 0 : 1 name = var.cluster_id resource_group_id = var.cluster_resource_group_id + wait_till = var.wait_till + wait_till_timeout = var.wait_till_timeout } # Download cluster config which is required to connect to cluster data "ibm_container_cluster_config" "cluster_config" { - cluster_name_id = var.cluster_id + cluster_name_id = var.is_vpc_cluster ? data.ibm_container_vpc_cluster.cluster[0].name : data.ibm_container_cluster.cluster[0].name resource_group_id = var.cluster_resource_group_id config_dir = "${path.module}/kubeconfig" endpoint_type = var.cluster_config_endpoint_type != "default" ? var.cluster_config_endpoint_type : null # null value represents default diff --git a/variables.tf b/variables.tf index aa446330..027fd930 100644 --- a/variables.tf +++ b/variables.tf @@ -29,6 +29,28 @@ variable "is_vpc_cluster" { default = true } +variable "wait_till" { + description = "To avoid long wait times when you run your Terraform code, you can specify the stage when you want Terraform to mark the cluster resource creation as completed. Depending on what stage you choose, the cluster creation might not be fully completed and continues to run in the background. However, your Terraform code can continue to run without waiting for the cluster to be fully created. Supported args are `MasterNodeReady`, `OneWorkerNodeReady`, `IngressReady` and `Normal`" + type = string + default = "Normal" + + validation { + error_message = "`wait_till` value must be one of `MasterNodeReady`, `OneWorkerNodeReady`, `IngressReady` or `Normal`." + condition = contains([ + "MasterNodeReady", + "OneWorkerNodeReady", + "IngressReady", + "Normal" + ], var.wait_till) + } +} + +variable "wait_till_timeout" { + description = "Timeout for wait_till in minutes." + type = number + default = 90 +} + ############################################################################## # Cloud Monitoring variables ##############################################################################