Regex in startup script

Hi there, I am trying to work with a Repository URL as a parameter and to provide the git command with valid repo link, I wanted to edit it, but my regex is getting catched by terraform.

This is part of the code.
# Check if the repo_url ends with a trailing slash or .git
if [[ $repo_url =~ /$ ]]; then
# Remove the trailing slash
repo_url="${repo_url%/}"
fi

and here is the error:
Error during the build
run parse: parse error: load module: ERROR: Invalid expression (main.tf:69) > Expected the start of an expression, but found an invalid expression token.

Any idea how to escape it or somehow let terraform not touch the regex? Its inside the startup script, so it should be fine.

Also I am thunking to add clarity to the code, can I somehow move the startup script away from main.tf and have a standalone file like startup.sh in the template files?
Was this page helpful?