Skip to main content
lower(str) returns a copy of str with all letters converted to lowercase.

Signature

lower(str string) string

Example

Normalize a branch name to lowercase before using it as a Docker image tag. Branch names may contain uppercase letters from conventions like feature/UserAuth, which are not valid in image tag format:
variable "branch" {
  description = "Git branch name"
  type        = string
}

computed "image_tag" {
  description = "Docker-safe image tag from the branch name"
  expression  = lower(replace(var.branch, "/", "-"))
}

task "build" {
  description = "Build a branch-tagged Docker image"
  commands    = ["docker build -t myapp:${computed.image_tag} ."]
}
feature/UserAuth becomes feature-userauth.

Notes

  • lower converts all Unicode letters, not just ASCII.
  • Pair lower with replace or regexreplace to sanitize strings for use in identifiers, tags, or filenames.