Created
May 25, 2020 12:11
-
-
Save pio2pio/e27f66ff4ed15221cd11519c71953501 to your computer and use it in GitHub Desktop.
Terraform template remove empty lines and comment lines starting with '#' symbol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "match_comment" { default = "/(?U)(?m)(?s)(^#.*$)/" } | |
variable "match_empty_line" { default = "/(?m)(?s)(^[\r\n])/" } | |
resource "helm_release" "myapp" { | |
name = "myapp" | |
chart = "${path.module}/charts/myapp" | |
values = [ | |
replace( | |
replace( | |
templatefile("${path.module}/templates/values-override.yaml.tpl", { | |
nfsServer = "k8s-nfs" | |
}), var.match_comment, ""), var.match_empty_line, "") | |
] | |
} | |
# Terraform regex is using re2 library | |
# * Regex flags are enabled by prefixinf the search: | |
# ** (?m) - multi-line mode (default false) | |
# ** (?s) - let . match \n (default false) | |
# ** (?U) - ungreedy (default false), so stop matching comments at EOL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment