-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresources.tf
54 lines (42 loc) · 1.45 KB
/
resources.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
locals {
rails_config_map_data = {
RAILS_SERVE_STATIC_FILES = "true",
RAILS_LOG_TO_STDOUT = "true"
}
config_map_data = merge(
var.is_rails_application ? local.rails_config_map_data : {},
try(yamldecode(file(var.config_variables_path)), {}),
var.config_variables,
)
config_map_hash = sha1(join("-", [for k, v in local.config_map_data : "${k}:${v}" if v != null]))
}
resource "kubernetes_config_map" "main" {
metadata {
name = "${var.service_short}-${var.environment}-${local.config_map_hash}"
namespace = var.namespace
}
data = local.config_map_data
}
module "application_secrets" {
source = "../secrets"
azure_resource_prefix = var.azure_resource_prefix
service_short = var.service_short
config_short = var.config_short
key_vault_short = var.secret_key_vault_short
}
locals {
secret_data = merge(
var.secret_yaml_key != null ? yamldecode(module.application_secrets.map[var.secret_yaml_key]) : {},
# Azure Key Vault disallows keys with underscores so we convert dashes to underscores
{ for k, v in module.application_secrets.map : replace(k, "-", "_") => v },
var.secret_variables,
)
secret_hash = sha1(join("-", [for k, v in local.secret_data : "${k}:${v}" if v != null]))
}
resource "kubernetes_secret" "main" {
metadata {
name = "${var.service_short}-${var.environment}-${local.secret_hash}"
namespace = var.namespace
}
data = local.secret_data
}