Loading...
Loading...
### Terraform Version ```shell Terraform v1.9.8 on windows_amd64 ``` ### Terraform Configuration Files ```terraform output test1 { value = replace("test.com", "\.", "-") } output test2 { value = replace("test.com", "\\.", "-") } ``` ### Expected Behavior Literal dot should be replaced by hyphen ``` Changes to Outputs: + test = "test-com" ``` ### Actual Behavior test1: ``` │ Error: Invalid escape sequence │ │ on main.tf line 2, in output "test": │ 2: value = replace("test.com", "\.", "-") │ │ The symbol "." is not a valid escape sequence selector. ``` test2: ``` Changes to Outputs: + test = "test.com" ``` ### Additional Context If I add escape sequences to the original string, then I get the expected results: ``` output test3 { value = replace("test\\.com", "\\.", "-") } ``` Result: ``` Changes to Outputs: + test = "test-com" ``` But, I can't do this, because I'm not using string literals, I'm accessing a string attribute from a resource. ``` output test4 { value = replace(some_resource.attribute, "\\.", "-") } ``` This also does not work ``` output test5 { value = replace("test.com", "[^a-zA-Z0-9]", "-") } ```
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.