From 43e14dd8e4b558ccb846ced8a855306cbd210be1 Mon Sep 17 00:00:00 2001 From: ababkin Date: Mon, 11 Oct 2021 18:03:49 +0600 Subject: [PATCH 1/6] add depends_on for all aws_eks_addon, add info about it to README.md --- terraform/layer1-aws/aws-eks.tf | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/terraform/layer1-aws/aws-eks.tf b/terraform/layer1-aws/aws-eks.tf index eca324fb..a9419d70 100644 --- a/terraform/layer1-aws/aws-eks.tf +++ b/terraform/layer1-aws/aws-eks.tf @@ -178,6 +178,7 @@ EOT }) } } + depends_on = [module.vpc] } @@ -192,6 +193,8 @@ resource "aws_eks_addon" "vpc_cni" { tags = { Environment = local.env } + + depends_on = [module.eks] } resource "aws_eks_addon" "kube_proxy" { @@ -205,6 +208,8 @@ resource "aws_eks_addon" "kube_proxy" { tags = { Environment = local.env } + + depends_on = [module.eks] } resource "aws_eks_addon" "coredns" { @@ -214,8 +219,10 @@ resource "aws_eks_addon" "coredns" { addon_name = "coredns" resolve_conflicts = "OVERWRITE" addon_version = var.addon_coredns_version - depends_on = [module.eks] + tags = { Environment = local.env } + + depends_on = [module.eks] } From e6eb2e41f29338e2cd0732aac749dca4f6cce05c Mon Sep 17 00:00:00 2001 From: ababkin Date: Mon, 11 Oct 2021 18:06:22 +0600 Subject: [PATCH 2/6] add depends_on for all aws_eks_addon, add info about it to README.md --- README.md | 13 +++++++++++++ terraform/layer2-k8s/.terraform.lock.hcl | 3 +++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 238d647c..da9a81d1 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ You can find more about this project in Anton Babenko stream: - [Base project name](#base-project-name) - [Unique prefix of resource names](#unique-prefix-of-resource-names) - [Separators](#separators) + - [Depends_on](#depends_on) - [Resource names](#resource-names) - [Variable names](#variable-names) - [Output names](#output-names) @@ -570,6 +571,18 @@ The `local.name` value is then used as a prefix for all `name` and `name_prefix` > Use `name_prefix` where possible +#### Depends_on + +- When you need to add depends_on to resource or module you should add it in end and put empty line in front of it. Example: +``` +resource "aws_eks_addon" "coredns" { + count = var.addon_create_coredns ? 1 : 0 + ... + + depends_on = [module.eks] +} +``` + #### Resource names - The resource type should not be duplicated in the resource name (either partially or in full): diff --git a/terraform/layer2-k8s/.terraform.lock.hcl b/terraform/layer2-k8s/.terraform.lock.hcl index d3266236..6a61ab29 100644 --- a/terraform/layer2-k8s/.terraform.lock.hcl +++ b/terraform/layer2-k8s/.terraform.lock.hcl @@ -6,6 +6,7 @@ provider "registry.terraform.io/hashicorp/aws" { constraints = "3.53.0" hashes = [ "h1:kcda9YVaFUzBFVtKXNZrQB801i2XkH1Y5gbdOHNpB38=", + "h1:oRCCzfwGCDNyuhIJ8kCg0N7h4W2WESm37o2GIt0ETpQ=", "zh:35a77c79170b0cf3fb7eb835f3ce0b715aeeceda0a259e96e49fed5a30cf6646", "zh:519d5470a932b1ec9a0fe08876c5e0f0f84f8e506b652c051e4ab708be081e89", "zh:58cfa5b454602d57c47acd15c2ad166a012574742cdbcf950787ce79b6510218", @@ -43,6 +44,7 @@ provider "registry.terraform.io/hashicorp/helm" { constraints = "2.2.0" hashes = [ "h1:liBgOoOXhA2A1DbL0oaifyNnoGOyHxMG4+xD1Kl58XA=", + "h1:rxDS2QQuG/M9aRSKlvW2oHsp5eGAoB1J9KZthCOVbeQ=", "zh:01341dd1e9cc7e7f6999e11e7473bcdca2dd72dd27f91beed1f4fb599a15dfba", "zh:20e86c9eccd3a81ef5ac243af31b61fc4d2d679437384bd0870e92fa1b3ed6c9", "zh:22a71127c5dbea4f62edb5bcf00b5c163de04aa19d45a7a1f621f973ffd09d20", @@ -62,6 +64,7 @@ provider "registry.terraform.io/hashicorp/kubernetes" { constraints = "2.4.1" hashes = [ "h1:RpE4kNQYkGxIyHyIEHXcdt/vKCtTVU2NNzTrOK4hb9E=", + "h1:wU6cDBN6KPhjbBvPWXRgryN9amNlhL/n9l39cFm3X/U=", "zh:10a368f3a3f26d821f02b55f0c42bdd4d2cd0dc5e2568c513bce39d92d25526f", "zh:2183272a6d44f23d562d47ff4d6592685d8797838bdae69a50f92121743b020f", "zh:24c492d61ce4dbcac4bb4410bd5e657ab28d19ab320d41104148ee626b44f5ed", From 6cc7685e73a388cd80716f685707d857da977978 Mon Sep 17 00:00:00 2001 From: ababkin Date: Mon, 11 Oct 2021 18:16:36 +0600 Subject: [PATCH 3/6] changed description in README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index da9a81d1..b8b252c4 100644 --- a/README.md +++ b/README.md @@ -573,12 +573,12 @@ The `local.name` value is then used as a prefix for all `name` and `name_prefix` #### Depends_on -- When you need to add depends_on to resource or module you should add it in end and put empty line in front of it. Example: +When you need to add depends_on to resource or module you should add it in end and put empty line in front of it. Example: ``` resource "aws_eks_addon" "coredns" { - count = var.addon_create_coredns ? 1 : 0 ... - + addon_version = var.addon_coredns_version + depends_on = [module.eks] } ``` From 187c18b2f2801c4c5979143931ad12ce3c4802ad Mon Sep 17 00:00:00 2001 From: ababkin Date: Mon, 11 Oct 2021 18:34:04 +0600 Subject: [PATCH 4/6] fix - terraform format --- README.md | 4 ++-- terraform/layer1-aws/aws-eks.tf | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b8b252c4..1bd1d5be 100644 --- a/README.md +++ b/README.md @@ -578,8 +578,8 @@ When you need to add depends_on to resource or module you should add it in end a resource "aws_eks_addon" "coredns" { ... addon_version = var.addon_coredns_version - - depends_on = [module.eks] + + depends_on = [module.eks] } ``` diff --git a/terraform/layer1-aws/aws-eks.tf b/terraform/layer1-aws/aws-eks.tf index a9419d70..6033d12c 100644 --- a/terraform/layer1-aws/aws-eks.tf +++ b/terraform/layer1-aws/aws-eks.tf @@ -194,7 +194,7 @@ resource "aws_eks_addon" "vpc_cni" { Environment = local.env } - depends_on = [module.eks] + depends_on = [module.eks] } resource "aws_eks_addon" "kube_proxy" { @@ -209,7 +209,7 @@ resource "aws_eks_addon" "kube_proxy" { Environment = local.env } - depends_on = [module.eks] + depends_on = [module.eks] } resource "aws_eks_addon" "coredns" { @@ -224,5 +224,5 @@ resource "aws_eks_addon" "coredns" { Environment = local.env } - depends_on = [module.eks] + depends_on = [module.eks] } From f50e4d20a9d86ccefe0747f41789e42b07b96caa Mon Sep 17 00:00:00 2001 From: ababkin Date: Tue, 12 Oct 2021 14:21:58 +0600 Subject: [PATCH 5/6] fix Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1bd1d5be..8aa584c4 100644 --- a/README.md +++ b/README.md @@ -573,7 +573,7 @@ The `local.name` value is then used as a prefix for all `name` and `name_prefix` #### Depends_on -When you need to add depends_on to resource or module you should add it in end and put empty line in front of it. Example: +When you need to add `depends_on` to resource or module you should add it in end and put empty line in front of it. Example: ``` resource "aws_eks_addon" "coredns" { ... From e2d8b09d27a6f62634423667ec10453a56bb6814 Mon Sep 17 00:00:00 2001 From: ababkin Date: Tue, 12 Oct 2021 14:34:59 +0600 Subject: [PATCH 6/6] fix formatting Readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8aa584c4..7128c850 100644 --- a/README.md +++ b/README.md @@ -573,7 +573,8 @@ The `local.name` value is then used as a prefix for all `name` and `name_prefix` #### Depends_on -When you need to add `depends_on` to resource or module you should add it in end and put empty line in front of it. Example: +When you need to add `depends_on` to a resource or a module you should put it at the end of the block with empty line in front of it. + ``` resource "aws_eks_addon" "coredns" { ...