Hitesh Sahu
Hitesh SahuHitesh Sahu
  1. Home
  2. ›
  3. posts
  4. ›
  5. …

  6. ›
  7. CLI

Loading ⏳
Please wait...

🍪 This website uses cookies

No personal data is stored on our servers however third party tools Google Analytics cookies to measure traffic and improve your website experience. Learn more

Cover Image for Terraform CMD Cheatsheet - String Functions

Terraform CMD Cheatsheet - String Functions

Cheatsheet for commonly used Terraform string functions

Hitesh Sahu
Hitesh Sahu

Mon Sep 29 2025

func output usage
startswith("hello world", "hello") true
endswith("hello world", "world") true
upper("hello") HELLO
lower("HELLO") hello
strrev("hello") olleh
substr("hello world", 1, 4) ello
title("hello world") Hello World
trim("?!hello?!", "!?") hello Removes the specified set of characters from the start and end of the given string.
trimsuffix("helloworld", "world") hello removes the specified suffix from the end of the given string.
trimprefix("helloworld", "hello") world removes the specified prefix from the start of the given string.
trimspace(" hello\n\n") hello removes any space characters from the start and end of the given string.
indent(2, "[\n foo,\n bar,\n]\n") items: [ foo,bar] adds a given number of spaces to the beginnings of all but the first line in a given multi-line string.
join("-", ["foo", "bar", "baz"]) "foo-bar-baz" produces a string by concatenating all of the elements of the specified list of strings with the specified separator.
replace("1 + 2 + 3", "+", "-") 1 - 2 - 3 searches a given string for another given substring, and replaces each occurrence with a given replacement string.
split(",", "foo,bar,baz") ["foo","bar","baz",] produces a list by dividing a given string at all occurrences of a given separator.