I have a list of GCP services, e.g. monitoring.googleapis.com
. I want to transform this list into a new list that contains a regex for each entry , e.g. monitoring\.googleapis\.com/.?
but I get the following error.
The symbol “.” is not a valid escape sequence selector.
variable "project_services" {
type = list(string)
default = [
"monitoring.googleapis.com",
"stackdriver.googleapis.com",
"compute.googleapis.com",
"bigquery.googleapis.com"
]
}
output "new_list"{
value = [for enabled_api in var.project_services: "${replace(enabled_api, ".", "\.")}/.?" ]
}
How can I get around this error?
Using value = [for enabled_api in var.project_services: "${replace(enabled_api, ".", "\\.")}/.?" ]
results in the below which is wrong.
new_list = [
"monitoring\\.googleapis\\.com/.?",
"stackdriver\\.googleapis\\.com/.?",
"compute\\.googleapis\\.com/.?",
"bigquery\\.googleapis\\.com/.?",
]