-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnullstone.tf
56 lines (52 loc) · 1.81 KB
/
nullstone.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
terraform {
required_providers {
ns = {
source = "nullstone-io/ns"
}
}
}
data "ns_workspace" "this" {}
// Generate a random suffix to ensure uniqueness of resources
resource "random_string" "resource_suffix" {
length = 5
lower = true
upper = false
numeric = false
special = false
}
locals {
tags = { for k, v in data.ns_workspace.this.tags : lower(k) => v }
block_name = data.ns_workspace.this.block_name
block_ref = data.ns_workspace.this.block_ref
resource_name = "${local.block_ref}-${random_string.resource_suffix.result}"
match_labels = {
"nullstone.io/stack" = data.ns_workspace.this.stack_name
"nullstone.io/block-ref" = data.ns_workspace.this.block_ref
"nullstone.io/env" = data.ns_workspace.this.env_name
}
labels = merge({
// k8s-recommended labels
"app.kubernetes.io/name" = local.block_name
"app.kubernetes.io/version" = local.app_version
"app.kubernetes.io/component" = ""
"app.kubernetes.io/part-of" = data.ns_workspace.this.stack_name
"app.kubernetes.io/managed-by" = "nullstone"
// nullstone labels
"nullstone.io/block" = data.ns_workspace.this.block_name
}, local.match_labels)
app_labels = merge({
// k8s-recommended labels
"app.kubernetes.io/name" = local.block_name
"app.kubernetes.io/version" = local.app_version
"app.kubernetes.io/component" = ""
"app.kubernetes.io/part-of" = data.ns_workspace.this.stack_name
"app.kubernetes.io/managed-by" = "nullstone"
// nullstone labels
"nullstone.io/app" = data.ns_workspace.this.block_name
}, local.match_labels)
repo_labels = {
"nullstone-stack" = data.ns_workspace.this.stack_name
"nullstone-block" = data.ns_workspace.this.block_name
"nullstone-env" = data.ns_workspace.this.env_name
}
}