-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add a homemade
depends_on
for MNG submodule to ensure orderin…
…g of resource creation (#867)
- Loading branch information
Showing
5 changed files
with
27 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,23 @@ | ||
# Hack to ensure ordering of resource creation. Do not create node_groups | ||
# before other resources are ready. Removes race conditions | ||
data "null_data_source" "node_groups" { | ||
count = var.create_eks ? 1 : 0 | ||
|
||
inputs = { | ||
cluster_name = coalescelist(aws_eks_cluster.this[*].name, [""])[0] | ||
|
||
# Ensure these resources are created before "unlocking" the data source. | ||
# `depends_on` causes a refresh on every run so is useless here. | ||
# [Re]creating or removing these resources will trigger recreation of Node Group resources | ||
aws_auth = coalescelist(kubernetes_config_map.aws_auth[*].id, [""])[0] | ||
role_NodePolicy = coalescelist(aws_iam_role_policy_attachment.workers_AmazonEKSWorkerNodePolicy[*].id, [""])[0] | ||
role_CNI_Policy = coalescelist(aws_iam_role_policy_attachment.workers_AmazonEKS_CNI_Policy[*].id, [""])[0] | ||
role_Container = coalescelist(aws_iam_role_policy_attachment.workers_AmazonEC2ContainerRegistryReadOnly[*].id, [""])[0] | ||
} | ||
} | ||
|
||
module "node_groups" { | ||
source = "./modules/node_groups" | ||
create_eks = var.create_eks | ||
cluster_name = coalescelist(data.null_data_source.node_groups[*].outputs["cluster_name"], [""])[0] | ||
cluster_name = coalescelist(aws_eks_cluster.this[*].name, [""])[0] | ||
default_iam_role_arn = coalescelist(aws_iam_role.workers[*].arn, [""])[0] | ||
workers_group_defaults = local.workers_group_defaults | ||
tags = var.tags | ||
node_groups_defaults = var.node_groups_defaults | ||
node_groups = var.node_groups | ||
|
||
# Hack to ensure ordering of resource creation. | ||
# This is a homemade `depends_on` https://discuss.hashicorp.com/t/tips-howto-implement-module-depends-on-emulation/2305/2 | ||
# Do not create node_groups before other resources are ready and removes race conditions | ||
# Ensure these resources are created before "unlocking" the data source. | ||
# Will be removed in Terraform 0.13 | ||
ng_depends_on = [ | ||
aws_eks_cluster.this, | ||
kubernetes_config_map.aws_auth, | ||
aws_iam_role_policy_attachment.workers_AmazonEKSWorkerNodePolicy, | ||
aws_iam_role_policy_attachment.workers_AmazonEKS_CNI_Policy, | ||
aws_iam_role_policy_attachment.workers_AmazonEC2ContainerRegistryReadOnly | ||
] | ||
} |