Skip to content

Commit 7d35a22

Browse files
committed
feat: Added configurable delay before addons creation
Currently, even though the cluster status is active, the addon API is not completely ready yet. This causes retries and significant delays during addon creation, potentially negating the before_compute delay.
1 parent 97a08c8 commit 7d35a22

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple
218218
| [aws_security_group.node](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
219219
| [aws_security_group_rule.cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
220220
| [aws_security_group_rule.node](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
221+
| [time_sleep.addon_delay](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
221222
| [time_sleep.this](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
222223
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
223224
| [aws_eks_addon_version.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_addon_version) | data source |
@@ -232,6 +233,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple
232233
| Name | Description | Type | Default | Required |
233234
|------|-------------|------|---------|:--------:|
234235
| <a name="input_access_entries"></a> [access\_entries](#input\_access\_entries) | Map of access entries to add to the cluster | `any` | `{}` | no |
236+
| <a name="input_addon_delay_duration"></a> [addon\_delay\_duration](#input\_addon\_delay\_duration) | Duration to wait after the EKS cluster has become active before creating the addons | `string` | `"0s"` | no |
235237
| <a name="input_attach_cluster_encryption_policy"></a> [attach\_cluster\_encryption\_policy](#input\_attach\_cluster\_encryption\_policy) | Indicates whether or not to attach an additional policy for the cluster IAM role to utilize the encryption key provided | `bool` | `true` | no |
236238
| <a name="input_authentication_mode"></a> [authentication\_mode](#input\_authentication\_mode) | The authentication mode for the cluster. Valid values are `CONFIG_MAP`, `API` or `API_AND_CONFIG_MAP` | `string` | `"API_AND_CONFIG_MAP"` | no |
237239
| <a name="input_bootstrap_self_managed_addons"></a> [bootstrap\_self\_managed\_addons](#input\_bootstrap\_self\_managed\_addons) | Indicates whether or not to bootstrap self-managed addons after the cluster has been created | `bool` | `null` | no |

main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,14 @@ data "aws_eks_addon_version" "this" {
489489
most_recent = try(each.value.most_recent, null)
490490
}
491491

492+
resource "time_sleep" "addon_delay" {
493+
count = length(var.cluster_addons) > 0 ? 1 : 0
494+
create_duration = var.addon_delay_duration
495+
triggers = {
496+
cluster_name = aws_eks_cluster.this[0].name
497+
}
498+
}
499+
492500
resource "aws_eks_addon" "this" {
493501
# Not supported on outposts
494502
for_each = { for k, v in var.cluster_addons : k => v if !try(v.before_compute, false) && local.create && !local.create_outposts_local_cluster }
@@ -523,6 +531,7 @@ resource "aws_eks_addon" "this" {
523531
module.fargate_profile,
524532
module.eks_managed_node_group,
525533
module.self_managed_node_group,
534+
time_sleep.addon_delay
526535
]
527536

528537
tags = merge(var.tags, try(each.value.tags, {}))
@@ -558,6 +567,10 @@ resource "aws_eks_addon" "before_compute" {
558567
delete = try(each.value.timeouts.delete, var.cluster_addons_timeouts.delete, null)
559568
}
560569

570+
depends_on = [
571+
time_sleep.addon_delay
572+
]
573+
561574
tags = merge(var.tags, try(each.value.tags, {}))
562575
}
563576

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,12 @@ variable "cluster_addons_timeouts" {
538538
default = {}
539539
}
540540

541+
variable "addon_delay_duration" {
542+
description = "Duration to wait after the EKS cluster has become active before creating the addons"
543+
type = string
544+
default = "0s"
545+
}
546+
541547
################################################################################
542548
# EKS Identity Provider
543549
################################################################################

0 commit comments

Comments
 (0)