From cb9f2d36a0696702a1190d98c997a92f28c15981 Mon Sep 17 00:00:00 2001 From: Mohamed Amine Dridi <78367821+modridi@users.noreply.github.com> Date: Mon, 30 Jan 2023 17:17:02 +0100 Subject: [PATCH] fix: remove circular dependency between app and secret (#32) * fix: remove circular dependency between app and secret * docs(terraform-docs): generate docs and write to README.adoc --------- Co-authored-by: modridi Release-As: v1.0.0-alpha.5 --- README.adoc | 6 ++++-- aks/README.adoc | 4 ++-- eks/README.adoc | 4 ++-- main.tf | 16 +++++++++++----- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.adoc b/README.adoc index 4c30f640..7bdd4590 100644 --- a/README.adoc +++ b/README.adoc @@ -27,6 +27,7 @@ The following resources are used by this module: - https://registry.terraform.io/providers/oboukili/argocd/latest/docs/resources/application[argocd_application.this] (resource) - https://registry.terraform.io/providers/oboukili/argocd/latest/docs/resources/project[argocd_project.this] (resource) +- https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace[kubernetes_namespace.kube_prometheus_stack_namespace] (resource) - https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret[kubernetes_secret.thanos_object_storage_secret] (resource) - https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource[null_resource.dependencies] (resource) - https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource[null_resource.this] (resource) @@ -154,7 +155,7 @@ Description: Override of target revision of the application chart. Type: `string` -Default: `"v1.0.0-alpha.3"` +Default: `"v1.0.0-alpha.4"` === Outputs @@ -206,6 +207,7 @@ Description: n/a |Name |Type |https://registry.terraform.io/providers/oboukili/argocd/latest/docs/resources/application[argocd_application.this] |resource |https://registry.terraform.io/providers/oboukili/argocd/latest/docs/resources/project[argocd_project.this] |resource +|https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace[kubernetes_namespace.kube_prometheus_stack_namespace] |resource |https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret[kubernetes_secret.thanos_object_storage_secret] |resource |https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource[null_resource.dependencies] |resource |https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource[null_resource.this] |resource @@ -314,7 +316,7 @@ object({ |[[input_target_revision]] <> |Override of target revision of the application chart. |`string` -|`"v1.0.0-alpha.3"` +|`"v1.0.0-alpha.4"` |no |=== diff --git a/aks/README.adoc b/aks/README.adoc index a156f453..e4abf0e4 100644 --- a/aks/README.adoc +++ b/aks/README.adoc @@ -168,7 +168,7 @@ Description: Override of target revision of the application chart. Type: `string` -Default: `"v1.0.0-alpha.3"` +Default: `"v1.0.0-alpha.4"` === Outputs @@ -328,7 +328,7 @@ object({ |[[input_target_revision]] <> |Override of target revision of the application chart. |`string` -|`"v1.0.0-alpha.3"` +|`"v1.0.0-alpha.4"` |no |=== diff --git a/eks/README.adoc b/eks/README.adoc index da7cd341..143cc578 100644 --- a/eks/README.adoc +++ b/eks/README.adoc @@ -157,7 +157,7 @@ Description: Override of target revision of the application chart. Type: `string` -Default: `"v1.0.0-alpha.3"` +Default: `"v1.0.0-alpha.4"` === Outputs @@ -310,7 +310,7 @@ object({ |[[input_target_revision]] <> |Override of target revision of the application chart. |`string` -|`"v1.0.0-alpha.3"` +|`"v1.0.0-alpha.4"` |no |=== diff --git a/main.tf b/main.tf index 1a41158b..b574b804 100644 --- a/main.tf +++ b/main.tf @@ -39,10 +39,14 @@ resource "argocd_project" "this" { } } +resource "kubernetes_namespace" "kube_prometheus_stack_namespace" { + metadata { + name = var.namespace + } +} + + resource "kubernetes_secret" "thanos_object_storage_secret" { - # This count here is nothing more than a way to conditionally deploy this - # resource. Although there is no loop inside the resource, if the condition - # is true, the resource is deployed because there is exactly one iteration. count = var.metrics_storage_main != null ? 1 : 0 metadata { @@ -55,7 +59,7 @@ resource "kubernetes_secret" "thanos_object_storage_secret" { } depends_on = [ - resource.argocd_application.this, + resource.kubernetes_namespace.kube_prometheus_stack_namespace ] } @@ -114,13 +118,15 @@ resource "argocd_application" "this" { } sync_options = [ - "CreateNamespace=true" + "CreateNamespace=false" ] } } depends_on = [ resource.null_resource.dependencies, + resource.kubernetes_secret.thanos_object_storage_secret, + resource.kubernetes_namespace.kube_prometheus_stack_namespace ] }