Terraform contd
- Terraform takes a folder as a input
- Terraform considers all the files which have extension of
.tf - Prompt:
According to google style guide for terraform give me standard terraform template structure - from now on
- providers -> providers.tf
- basic resources -> main.tf and others as required
- variables -> variables.tf
- outputs -> outputs.tf
- Refer Here for the changes done
Variables in Terraform
- Refer Here for variables and Refer Here for variable block
-
Prompt:
According to google style guide for terraform give me standard terraform variable naming conventions -
Variables can be passed during terraform execution
terraform apply -var "network_cidr=10.0.0.0/16" -var "network_name_tag=my-first-vpc" -
If number of varaibles are more we can create a file and pass that file to terraform Refer Here. This file has extension of
.tfvars -
To apply variable from file during execution
terraform apply -var-file='example.tfvars' - in some case we might be using both -var and -var-file, in that case -var will be priority
- Refer Here for changes with variables and for vars file Refer Here
Attributes
- Attributes refer to the output created
- To view attributes use docs or console (after creation)
- resource id in terraform
type.label
Order of creation
Example
- In the current network or vpc lets add 4 subnets
- To be discussed
