DELAPARRA
Index
Color
NL
Category: Terraform

interpolation

Explained by Updated

What is interpolation?

interpolation: Embedding an expression inside a string with ${...}. In HCL2 you rarely need it for whole values — bare references work. Interpolation embeds an expression in a string, using ${...} in Terraform. name = "web-${var.env}" produces web-production when the environment is production. In older Terraform versions you needed interpolation syntax for every reference. Since Terraform 0.12, you can use references directly, so instance_type = var.size is the clean form and "${var.size}" is unnecessary.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about interpolation

What should you keep in mind with interpolation?

Keep interpolation for building strings from several parts, such as resource names and tags. Use a consistent naming pattern across all resources, such as project, environment and role, so you can recognise them in the cloud console and on invoices. For more complex string building, format() and join() are often clearer than long interpolated strings.

What does an example of interpolation look like?

name = "web-${var.env}-${count.index}"

At a glance

CategoryTerraform
Explained by
Updated

More Terraform terms

All terms starting with I

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.