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

Signature

upper(str string) string

Example

Normalize an environment name to uppercase for use as a configuration key prefix:
variable "env" {
  description = "Deployment environment"
  type        = string
  default     = "staging"
}

computed "env_prefix" {
  description = "Uppercase environment prefix for config keys"
  expression  = upper(var.env)
}

task "deploy" {
  description = "Deploy using environment-specific configuration"
  commands = [
    "kubectl apply -f k8s/${var.env}/",
    "kubectl set env deployment/app ENV=${computed.env_prefix}",
  ]
}
staging becomes STAGING.

Notes

  • upper converts all Unicode letters, not just ASCII.
  • Pair upper with other string functions to build identifiers or keys that follow uppercase conventions.