loops in Terraform
Count meta argument
- Refer Here for official docs
Activity 2.2: use count to create multiple subnets in a loop
- Refer Here for changes.
Activity 1.2: Lets change the vpc template and
- Lets ask the user the vpc cidr range and subnet cidr ranges
- Lets ask the user for the Name of vpc and subnets
- Also implement count to create 4 subnets
- inputs to vpc
- cidr block
- tags
- inputs to subnet
- cidr block
- availability zone
- tags
- Refer Here for the changes done
Activity 2.3 use complex variables in azure
- Refer Here for changes done to include complex variables.
Passing variables during apply
- we have already looked at option
terraform apply -var <var-name>='value' - Terraform also gives us an option to pass multiple variables at one shot in variables file
- This variables file will have extension of
.tfvarsand to pass it during applyterraform apply -var-file='dev.tfvars'
Activity 1.3 use variables file for aws template
- we have created a file called
dev.tfvarswhich represents values for dev environment - Command used to create infra
terraform apply -var-file='dev.tfvars'
- Refer Here
- Exercise: DO the same for azure
Terraform functions
- Refer Here for the official docs of terraform functions
Activity 1.4: Use function to get how many subnets to be created
- Refer Here
- Apply the same for azure Refer Here
