Terraform Variables

Terraform Variables

Terraform Variables

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

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


In this blog post, we will discuss terraform variables.

What is Terraform variable?

Variable provides a way to dynamically assign a value to an attribute in terraform code. Using variable, you can modularize your code for reuse. Instead of assigning values directly to the attributes you can define a variable and refer it in your code. In the future, if you want any modification to your infrastructure or apply any change, you can simply edit the variable block or file. Terraform provide us two way to use variables, directly in your main.tf file or using a separate variable file named terraform.tfvars. In this demo, we will explore inline variables.

Variable Syntax:

Variable demo:

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

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



Leave a Reply

Close Menu