I have a Kafka client container running on AWS ECS, which should receive a regular expression for which topics to subscribe to from the containers environment variables. In my terraform I define the environment variable like so:
..
{
"name": "KAFKA_TOPIC_REGEX",
"value": "${local.kafka_topic_regex[local.environment]}"
}
..
With a corresponding value in the locals.tf file like so:
..
kafka_topic_regex = {
development = "^(ab\..*\..*)$|^(foo\.bar)$"
}
..
However I'm having difficulty getting this to work as expected. When I terraform plan, the following error is shown:
The symbol "." is not a valid escape sequence selector.
Unfortunately I need the backward slash there for the regex to use the literal dot as a character in the topic name. I can't escape the backward slash as I actually require it be there for the regex.
I have equally tried the regex like so:
^(ab[.].*[.].*)$|^(foo[.]bar)$
Again, Terraform does some strange interpretation of this and in the plan the value appears as:
^ab.(.*)
This will mean that the literal dot I require isn't in the regex as it is required to be escaped in the regex.
It appears Terraform is interpreting my string and causing a failed plan / apply, when it shouldn't be interpreting it.
Any help would be appreciated, thank you