You are currently viewing Terraform Locals

Terraform Locals

Terraform Locals

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed terraform backends.

https://cloudaffaire.com/terraform-backends/

In this blog post, we will discuss terraform locals.

What is terraform local?

The local block defines one or more local variables within a module. Comparing modules to functions in a traditional programming language, if input variables are analogous to function arguments and outputs values are analogous to function return values, then local values are comparable to a function’s local temporary symbols.

Each locals block can have as many locals as needed, and there can be any number of locals blocks within a module. The names given for the items in the local block must be unique throughout a module. The given value can be any expression that is valid within the current module. The expression of a local value can refer to other locals, but as usual reference cycles are not allowed. That is, a local cannot refer to itself or to a variable that refers (directly or indirectly) back to it.

Next, we are going to explain terraform locals with a demo.

Terraform locals:

Hope you have enjoyed this article. In the next blog post, we will discuss terraform imports.

To get more details on terraform, please refer below terraform documentation.

https://www.terraform.io/docs/index.html

 

Leave a Reply