Day-2
Today I have to learn variables in terraform
Step-1 Create first.tf file
To run this file we have to use the terraform plan command.
if I run this command they ask for a username on the command line to solve this we have to pass a variable value in the command line.
terraform plan -var username=demo
In the previous post, we saw that we can put multiple terraform configuration files in the same directory. let's implement it and divide the above first.tf file.
let's create a file variable.tf with the below content, in this file, we will only define the variables.
output. tf file for showing results.
terraform plan -var username=monish -var age=45
In the available block, we have also defined parameters like type, default, and description.
if you define a parameter in a variable block then you can directly run the plan command to show the default value.
In the next article, we have to learn the type of variable.
string, number, bool, map, list.
Subscribe to my newsletter
Read articles from dhirendra directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by