cbhenderson | 2024-03-08 17:57:19 UTC | #1
I have encountered an issue when using "includefilterresources" in a terraform export block. I am trying to match a datatable named "8559 Contact Center (TEST)"
The include filter I tried is: "genesyscloudarchitectdatatable::^8559 Contact Center \(TEST\)$" which escapes the parentheses characters.
When I run terraform plan, the following is generated:
│ Error: Invalid escape sequence │ │ on main.tf line 18, in resource "genesyscloudtfexport" "export": │ 18: "genesyscloudarchitectdatatable::^8559 Contact Center \(TEST\)$" │ │ The symbol "(" is not a valid escape sequence selector.
│ Error: Invalid escape sequence │ │ on main.tf line 18, in resource "genesyscloudtfexport" "export": │ 18: "genesyscloudarchitectdatatable::^8559 Contact Center \(TEST\)$" │ │ The symbol ")" is not a valid escape sequence selector.
Even though the regex after the :: is correct and validates a match against the string "8559 Contact Center (TEST)" string in a regex validation tool.
Does anyone have a solution to this issue? The client tends to use parenthetical descriptors in many of their object names.
Thank you
cbhenderson | 2024-03-08 17:58:53 UTC | #2
Please note that all of the ( and ) characters in the terraform files are escaped with a backslash \ character. The backslashes were stripped out of the message when I posted it
John_Carnell | 2024-03-08 18:39:30 UTC | #3
Hi Craig,
Can you please post an example of the filtered list? I am going on PTO for next week, but I will have someone on my team take a look at it.
Thanks, John Carnell Director, Developer Engagement
cbhenderson | 2024-03-08 22:41:54 UTC | #4
John, Enjoy your PTO! I have uploaded a sample.tf (with extension yml) file that has terraform commands I'm trying to use to export a specific data table. The output of the terraform plan command is in the original post. Thank you for having someone take a look at this. --craig
sample.yml|attachment (490 Bytes)
Hemanth | 2024-03-12 19:48:32 UTC | #5
cbhenderson, post:1, topic:25102
8559 Contact Center (TEST)"
Hi @cbhenderson
Terraform by default doesnot identify string after :: in includefilterresources as a regex string. Only the provider parses the string and assumes the later part of string as regex. Generally regex ^8559 Contact Center \(TEST\)$ would help you to match your desired dataTable Name . with "\" as an escape character for "("
But with terraform string interpolation , if you we need to have a literal backslash as an escape character in regex, you need to have double \
https://developer.hashicorp.com/terraform/language/expressions/strings#escape-sequences
Can you try with
and let us know if it works for you.
Thanks Hemanth
cbhenderson | 2024-03-13 19:56:13 UTC | #6
Hi @Hemanth I'm happy to report that your suggested syntax resolved the issue of escaping the "(" and ")" characters. Thank you! I have one additional question: The export command created a resource definition of the datatable in the genesyscloud directory. I would like to modify the resource file definition and then run a terraform import block to create a slightly modified datatable in a different Genesys ORG. Do you know of a way to create a terraform.tfstate file from the resource definition in the import block of the .tf file I've edited?
Thank you!
Hemanth | 2024-03-15 13:00:05 UTC | #7
hi @cbhenderson
If I understand the question correctly, you can modify resource definition in the exported tf file and apply it in a different ORG. Once you do an import/Apply of a terraform resource, terraform would automatically create a state file for you. We dont need to modify/create a tfstate file ourselves. Hope this clarifies.
Thanks Hemanth
cbhenderson | 2024-03-25 16:05:30 UTC | #8
hi, Hemanth, That solved my issue. Thank you!
system | 2024-04-24 16:05:59 UTC | #9
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 25102