From the course: Terraform: Managing Network Infrastructure
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Looping over subnets with Terraform count - Terraform Tutorial
From the course: Terraform: Managing Network Infrastructure
Looping over subnets with Terraform count
- [Instructor] Every design out there is probably going to have more than one subnet. Now I could just duplicate this block here, but instead of adding more unnecessary lines to our configuration files, in this video what we're going to look at is one of Terraform's meta-arguments called count and also a handy function in Terraform called cidrsubnet. So let's start out with the flow of information in. I have these two subnet variables here and I'm going to go ahead and rename this one to subnets and I'm going to change the type to a list of strings. And what this is going to do is Terraform is going to expect a list of strings for subnets and we're just going to provide it basically a list of names. So I'm going to go ahead and remove this other variable here. Save this. Now I'm going to hop over to the terraform.tfvars file and I'm just going to remove both of these and create a subnets value. So this is going to be…