diff --git a/README.md b/README.md index 238d647c..7128c850 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,19 @@ 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 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" { + ... + addon_version = var.addon_coredns_version + + 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/layer1-aws/aws-eks.tf b/terraform/layer1-aws/aws-eks.tf index eca324fb..6033d12c 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] } 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",