Terraform documentation says that “Backslash sequences are not interpreted in a heredoc string”, but I have an issue when two consecutive backslashes are replaced with four backslashes.
In order to create aws_glue_catalog_table for vpc flow logs I’m using regex saved in heredoc format and referencing it as input.regex parameter.
When plan is printed, every double backslash is replaced with four backslashes.
Using Terraform v0.12.29
vpc_flow_log_regex = <<EOF
^([^ ]+)\\s+([0-9]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([^ ]+)\\s+([0-9]+)\\s+([0-9]+)\\s+([^ ]+)\\s+([^ ]+)$
EOF
resource "aws_glue_catalog_table" "vpc_flow_logs" {
...
parameters = {
"serialization.format" = "1"
"input.regex" = trimspace(local.vpc_flow_log_regex)
}
Plan output:
+ parameters = {
+ "input.regex" = "^([^ ]+)\\\\s+([0-9]+)\\\\s+([^ ]+)\\\\s+([^ ]+)\\\\s+([^ ]+)\\\\s+([^ ]+)\\\\s+([^ ]+)\\\\s+([^ ]+)\\\\s+([^ ]+)\\\\s+([^ ]+)\\\\s+([0-9]+)\\\\s+([0-9]+)\\\\s+([^ ]+)\\\\s+([^ ]+)$"
+ "serialization.format" = "1"