Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create a slug function for terraform core #36472

Open
ryanpodonnell1 opened this issue Feb 11, 2025 · 2 comments · May be fixed by #36552
Open

create a slug function for terraform core #36472

ryanpodonnell1 opened this issue Feb 11, 2025 · 2 comments · May be fixed by #36552
Labels
enhancement functions new new issue not yet triaged

Comments

@ryanpodonnell1
Copy link

ryanpodonnell1 commented Feb 11, 2025

Terraform Version

Terraform v1.9.8
on linux_amd64

Use Cases

I would like to request a slug function be added. Currently there is a great provider that offers this but feels fairly useful for things like templating dynamic vars which dont allow spaces or special chars in the key or URL creation

example:

variable "custom_object" {
default = {
"a value (1)" = ["one","two"]
"a value (2)" = ["three"]
      }
}
....
locals {
slugify_custom_object                 = { for k2, v2 in var.custom_object : slug(k2) => jsonencode(v2) }
template_string = "template_me: ${a-value-1}"
template = try(templatestring(local.template_string,local.slugify_custom_object),null)
}

Attempted Solutions

requires a custom/3rd party provider

variable "custom_object" {
default = {
"a value (1)" = ["one","two"]
"a value (2)" = ["three"]
      }
}
....
locals {
slugify_custom_object                 = { for k2, v2 in var.custom_object : provider::slugify::slug(k2) => jsonencode(v2) }
template_string = "template_me: ${a-value-1}"
template = try(templatestring(local.template_string,local.slugify_custom_object),null)
}

Proposal

add slug() function to terraform

References

No response

@ryanpodonnell1 ryanpodonnell1 added enhancement new new issue not yet triaged labels Feb 11, 2025
@crw crw added the functions label Feb 11, 2025
@crw
Copy link
Contributor

crw commented Feb 11, 2025

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!

@ryanpodonnell1
Copy link
Author

ryanpodonnell1 commented Feb 20, 2025

starting throwing together something #36552

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement functions new new issue not yet triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants