Terraform export regex issue

I have encountered an issue when using "include_filter_resources" in a terraform export block.
I am trying to match a datatable named "8559 Contact Center (TEST)"

The include filter I tried is:
"genesyscloud_architect_datatable::^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 "genesyscloud_tf_export" "export":
│ 18: "genesyscloud_architect_datatable::^8559 Contact Center (TEST)$"

│ The symbol "(" is not a valid escape sequence selector.

│ Error: Invalid escape sequence

│ on main.tf line 18, in resource "genesyscloud_tf_export" "export":
│ 18: "genesyscloud_architect_datatable::^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

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

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

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 (490 Bytes)

Hi @cbhenderson

Terraform by default doesnot identify string after :: in include_filter_resources 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 \

Can you try with

and let us know if it works for you.

Thanks
Hemanth

1 Like

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!

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

hi, Hemanth,
That solved my issue. Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.