variables in Terraform are quite important, as you need to hold values of names of instance, configs , etc.
We can create a variables.tf file which will hold all the variables.
variable "filename" {
default = "/home/ubuntu/terrform-tutorials/terraform-variables/demo-var.txt"
}
variable "content" {
default = "This is coming from a variable which was updated"
}
These variables can be accessed by var object in main.tf
- Create a local file using Terraform Hint:
resource "local_file" "devops" {
filename = var.filename
content = var.content
}
variable "file_contents" {
type = map
default = {
"statement1" = "this is cool"
"statement2" = "this is cooler"
}
}
- Use terraform to demonstrate usage of List, Set and Object datatypes
- Put proper screenshots of the outputs
Use terraform refresh
To refresh the state by your configuration file, reloads the variables
I can imagine, Terraform can be tricky, so best to use a Free video Course for terraform here
Happy Learning :)