Terraform regex function not found

I have this in my tf file:

locals {
  environment       = regex("^(?P<name>(?P<type>[a-zA-Z]*)(?P<num>\\d*))$",terraform.workspace)

When I apply it I’m getting:

Error: Call to unknown function

  on main.tf line 40, in locals:
  40:   environment       = regex("^(?P<name>(?P<type>[a-zA-Z]*)(?P<num>\\d*))$",terraform.workspace)
    | terraform.workspace is "dev22"

terraform --version:
Terraform v0.12.6

Any ideas why it can’t find the function?

Hi @Richard-Payne,

The regex and regexall functions were introduced in v0.12.7, so they are not available in v0.12.6.

ok, thanks Martin. Have I missed it or is the documentation lacking here:

The documentation always reflects the latest functionality. We do not currently have documentation published for older versions of Terraform.

Is that a design choice or just a factor of Terraform not being v1 release yet?

Ansible does this and it is incredibly useful.

Honestly, it is just that available development time is finite and we’ve been spending it elsewhere.

As a compromise, we currently maintain docs for the configuration language for both Terraform v0.11 and v0.12, but each of those always reflects the latest minor release in each major line because the changes between minor releases are generally small.