Render a file template with variables.

Section: Expressions and Functions

templatefile function

hcl
hcl
user_data = templatefile("${path.module}/user-data.sh.tftpl", {
  environment = var.environment
})
Explanation

Render a file template with variables.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Expressions and Functions
Merge maps
Combine multiple maps into one.
OpenIn sheethclsame section
try and can
Handle optional values and guard against invalid access.
OpenIn sheethclsame section
Conditional expression
Choose values conditionally.
OpenIn sheethclsame section
For expression
Transform collections with a for expression.
OpenIn sheethclsame section
String variable
Declare a typed string variable.
OpenIn sheethcl1 tag match
Use count
Create multiple similar resources with count.
OpenIn sheethcl1 tag match