From the course: HashiCorp Certified: Terraform Associate (003) Cert Prep by KodeKloud
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Using variables - Terraform Tutorial
From the course: HashiCorp Certified: Terraform Associate (003) Cert Prep by KodeKloud
Using variables
- [Instructor] Let us now recap how to use variables within our Terraform configuration. As we saw in the previous lecture, a variable block is perfectly valid even if it has no arguments defined inside. In this case, since we have not specified a default value, we would have to pass in the values during the Terraform execution using one of the several methods that we saw earlier. A default value may be added for any variable using the default argument. We can also optionally add a description. It's a good practice to make use of this argument to specify what this variable is used for. Then we have the type argument, which as the name suggests, defines the type of data that the variable accepts. Another optional argument is sensitive. It can take a Boolean value of true or false, false being the default. Now, if it is set to true, the variable value will be suppressed when running operations such as terraform plan or apply. Now, these values, however, will be recorded in the Terraform…