Skip to content

Commit

Permalink
rudimentary support for secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Schoenborn committed Mar 26, 2021
1 parent 324efda commit 7bc5c3b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,17 @@ resource "local_file" "config_roots_no_tmpl_found" {
config_roots_no_override_tmpl = keys(local.config_roots_no_tmpl_overrides)
})
}

resource "null_resource" "sops_encrypt_secrets" {
for_each = {for k,v in local.all_tmpl_files: k => v if length(regexall(var.encrypt_fileset_re, v)) > 0}
depends_on = [local_file.config_values]

triggers = {
# Only re-encrypt if the content has changed since last
environment_infra_yaml_updated = local_file.config_values[each.key].id
}

provisioner "local-exec" {
command = "${var.encrypt_command} ${each.value}"
}
}
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ variable "output_config_roots_no_tmpl_found" {
default = false
}

variable "encrypt_fileset_re" {
type = string
description = "Regular expression to identify rendered files which need to be encrypted"
default = "/secrets-*.yaml$"
}

variable "encrypt_command" {
type = string
description = "Command to encrypt a rendered file (the file will be appended as last arg)"
default = "sops -e -i"
}

variable "save_config_roots_no_tmpl_found" {
type = bool
description = "If true, will create file in path.root, containing config_roots that did not have any filesets"
Expand Down

0 comments on commit 7bc5c3b

Please sign in to comment.