terra_madre/common

Values

pub fn sanitize_terraform_identifier(name: String) -> String

Sanitize string to valid Terraform resource name.

Per Terraform docs (https://developer.hashicorp.com/terraform/language/syntax/configuration):

  • Identifiers can contain letters, digits, underscores (_), and hyphens (-)
  • The first character must not be a digit

This function:

  • Replaces illegal characters with underscores
  • Prefixes with underscore if name starts with a digit
Search Document