Argument definition must end with a newline. error

Team,

when i use below query in terraform script and ran in jenkin job(unix), seeing new line error. please help

query = "logs(/"service:expert-search-indexing-service /"*indexing*/" /").index(/"*/").rollup(/"count/").last(/"1m/") >= 1 "
e[0mOn ../../../modules/datadogMonitor/indexing.tf line 18: An argument definition
must end with a newline.

Hi @naresh.ns8!

It looks like you used slashes / instead of backslashes \ to escape the special characters in your quoted string template, and so Terraform’s parser thinks you intended the string to end at the first non-escaped quote mark.

If you use backslashes instead then I expect it will work. Alternatively, you can avoid the need to escape those by using the multi-line template syntax, like this:

query = <<-EOQ
  logs("service:expert-search-indexing-service "*indexing*" ").index("*").rollup("count").last("1m") >= 1
EOQ

With this multi-line syntax, the <<<-EOQ marker says to treat the following lines in their entirety as part of the template until finding a line that contains just EOQ. The name “EOQ” can be any identifier here, as long as the start and end both match; I intended this abbreviation to mean “end of query” in this case.