Terraform contd
AWS: Create a VPC with 4 subnets revisited
- Overview

Variables
- Terraform variables allows users to pass the values during execution
- Variable block supports the arguments as listed here
- syntax
variable <name> {
type =
}
- Generally as per google’s style guide we create all the variables in variables.tf or inputs.tf
- To use the variable the syntax is
var.<name> - Refer Here for the variables added to aws vpc and 4 subnets
- We can create a file
<name>.tfvarswhere we can apply all the values and pass this file during terraform apply - Generally we will have
<environment>.tfvars - Refer Here for changes done
- Few variables to pass
terraform apply -var var1=value1 -var var2=value2
- many variables to pass, create a .tfvars file such as dev.tfvars
terraform apply -var-file="dev.tfvars"
- Refer Here for variables with object types
