How to assign a value to a string variable, that includes embedded '=' in the value

33 Views Asked by At

With a value such as:

s = "https://xxx.yyy.com/oauth2/v1/token?grant_type=client_zzzz"

Terraform complains, when try to escape the embedded =. Seemingly, it has no issue, with certain other special chars, such as ?.

Aside from direct escape (\), I also tried format(), with various modifiers. No luck....

If I just use the native format to assign, it renders the value as: &#061


used a direct escape \=, within the string, and, also the format""%s", var).

1

There are 1 best solutions below

3
Syed Danish Khawar On
s = replace("https://xxx.yyy.com/oauth2/v1/token?grant_type=client_zzzz", "=", "&#061")

This will replace all occurrences of '=' with '&#061' in your string 's'. You can use similar approach for other special characters as well.