Skip to content

Commit

Permalink
fix: do not delay Helm values evaluation
Browse files Browse the repository at this point in the history
This is a dirty hack to work around a limitation of module dependencies
which delays the evaluation of data sources.
  • Loading branch information
John Doe authored and fsismondi committed May 4, 2022
1 parent d777afb commit 9c50d4d
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 34 deletions.
62 changes: 31 additions & 31 deletions aks/local.tf
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
locals {
helm_values = [{
loki-stack = {
loki = {
config = {
schema_config = {
configs = [
{
from = "2020-12-22"
store = "boltdb-shipper"
object_store = "azure"
schema = "v11"
index = {
prefix = "index_"
period = "24h"
}
},
]
}
storage_config = {
azure = {
container_name = "${azurerm_storage_container.loki.name}"
account_name = "${azurerm_storage_account.this.name}"
account_key = "${azurerm_storage_account.this.primary_access_key}"
}
boltdb_shipper = {
active_index_directory = "/data/loki/index"
shared_store = "azure"
cache_location = "/data/loki/boltdb-cache"
}
}
helm_values = [{
loki-stack = {
loki = {
config = {
schema_config = {
configs = [
{
from = "2020-12-22"
store = "boltdb-shipper"
object_store = "azure"
schema = "v11"
index = {
prefix = "index_"
period = "24h"
}
},
]
}
storage_config = {
azure = {
container_name = "${azurerm_storage_container.loki.name}"
account_name = "${azurerm_storage_account.this.name}"
account_key = "${azurerm_storage_account.this.primary_access_key}"
}
boltdb_shipper = {
active_index_directory = "/data/loki/index"
shared_store = "azure"
cache_location = "/data/loki/boltdb-cache"
}
}
}
}]
}
}
}]
}
6 changes: 3 additions & 3 deletions aks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module "loki-stack" {
cluster_name = var.cluster_name
base_domain = var.base_domain
argocd_namespace = var.argocd_namespace
namespace = var.namespace

helm_values = concat(local.helm_values, var.helm_values)
namespace = var.namespace
helm_values = concat(local.helm_values, var.helm_values)
dependency_ids = var.dependency_ids
}
3 changes: 3 additions & 0 deletions aks/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "id" {
value = module.loki-stack.id
}
2 changes: 2 additions & 0 deletions eks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,6 @@ module "loki-stack" {
bucket_name = aws_s3_bucket.loki.id,
assumable_role_arn = module.iam_assumable_role_loki.iam_role_arn,
})], var.extra_yaml)

dependency_ids = var.dependency_ids
}
3 changes: 3 additions & 0 deletions eks/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "id" {
value = module.loki-stack.id
}
2 changes: 2 additions & 0 deletions k3s/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ module "loki-stack" {
minio_access_key = var.minio.access_key,
minio_secret_key = var.minio.secret_key,
})], var.extra_yaml)

dependency_ids = var.dependency_ids
}
3 changes: 3 additions & 0 deletions k3s/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "id" {
value = module.loki-stack.id
}
14 changes: 14 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
resource "null_resource" "dependencies" {
triggers = var.dependency_ids
}

resource "argocd_project" "this" {
metadata {
name = "loki-stack"
Expand Down Expand Up @@ -76,4 +80,14 @@ resource "argocd_application" "this" {
]
}
}

depends_on = [
resource.null_resource.dependencies,
]
}

resource "null_resource" "this" {
depends_on = [
resource.argocd_application.this,
]
}
3 changes: 3 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "id" {
value = resource.null_resource.this.id
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ variable "helm_values" {
default = []
}

variable "dependency_ids" {
type = map(string)

default = {}
}

#######################
## Module variables
#######################

0 comments on commit 9c50d4d

Please sign in to comment.