Skip to content

Commit

Permalink
feat(azure): add module
Browse files Browse the repository at this point in the history
  • Loading branch information
modridi committed Apr 12, 2022
1 parent 55681a6 commit c6f4784
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 42 deletions.
2 changes: 1 addition & 1 deletion aks/extra-variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ variable "storage_account_tier" {

variable "storage_account_replication_type" {
description = "Storage account replication type for storing loki logs"
default = "GRS"
default = "LRS"
type = string
}

Expand Down
36 changes: 36 additions & 0 deletions aks/local.tf
Original file line number Diff line number Diff line change
@@ -0,0 +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"
}
}
}
}
}
}]
}
7 changes: 1 addition & 6 deletions aks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ module "loki-stack" {
cluster_name = var.cluster_name
base_domain = var.base_domain
argocd_namespace = var.argocd_namespace

namespace = var.namespace

extra_yaml = concat([templatefile("${path.module}/values.tmpl.yaml", {
loki_container_name = azurerm_storage_container.loki.name,
loki_account_name = azurerm_storage_account.this.name,
loki_account_key = azurerm_storage_account.this.primary_access_key,
})], var.extra_yaml)
helm_values = concat(local.helm_values, var.helm_values)
}
24 changes: 0 additions & 24 deletions aks/values.tmpl.yaml

This file was deleted.

4 changes: 1 addition & 3 deletions local.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
locals {
default_yaml = [templatefile("${path.module}/values.tmpl.yaml", {
})]
all_yaml = concat(local.default_yaml, var.extra_yaml)
helm_values = [{}]
}
15 changes: 12 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ resource "argocd_project" "this" {
}

data "utils_deep_merge_yaml" "values" {
input = local.all_yaml
input = [for i in concat(local.helm_values, var.helm_values) : yamlencode(i)]
}

resource "argocd_application" "this" {
Expand Down Expand Up @@ -56,8 +56,17 @@ resource "argocd_application" "this" {

sync_policy {
automated = {
prune = true
self_heal = true
allow_empty = false
prune = true
self_heal = true
}

retry {
backoff = {
duration = ""
max_duration = ""
}
limit = "0"
}

sync_options = [
Expand Down
Empty file removed outputs.tf
Empty file.
2 changes: 0 additions & 2 deletions values.tmpl.yaml

This file was deleted.

7 changes: 4 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ variable "namespace" {
default = "loki-stack"
}

variable "extra_yaml" {
type = list(string)
default = []
variable "helm_values" {
description = "Helm values, passed as a list of HCL structures."
type = any
default = []
}

#######################
Expand Down

0 comments on commit c6f4784

Please sign in to comment.