Hi,
Why can you not use the cidrsubnet function?
It would help if we know the address space for the VPC and what you want in terms of subnets.
Andrew.
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
terraform-too...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/terraform-tool/8c94aba4-b717-4bb4-8f73-f5d2d0934e30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/54baf266-d632-4a2f-bdfa-1c2c2e9e8506%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com<mailto:terraform-tool+unsubscribe@googlegroups.com>.
Hi,
Try this:
# First set of 3 /24 subnets
cidr_block = "${cidrsubnet(10.25.0.0/16, 8, count.index)}" # 10.25.0.0/24, 10.25.1.0/24, 10.25.2.0/24 and 10.25.3.0/24
# Second set of 3 /24 subnets
cidr_block = "${cidrsubnet(10.25.0.0/16, 8, count.index + 4)}" # 10.25.4.0/24, 10.25.5.0/24, 10.25.6.0/24 and 10.25.7.0/24
# Third set of 3 /24 subnets
cidr_block = "${cidrsubnet(10.25.0.0/16, 8, count.index + 8)}" # 10.25.8.0/24, 10.25.9.0/24, 10.25.10.0/24 and 10.25.11.0/24
# First set of /22 subnets after the /24 subnets
cidr_block = "${cidrsubnet(10.25.0.0/16, 6, count.index + 3)}" # 10.25.12.0/22, 10.25.16.0/22, 10.25.19.0/22 and 10.25.23.0/22
The netnum parameter is the number of the subnet in the given range (i.e, the bits you are specifying in the second parameter).
So, for example, if you wanted to put some more /24 subnets after 10.25.23.255 starting from 10.25.24.0, you would use something like this:
cidr_block = "${cidrsubnet(10.25.0.0/16, 24, count.index)}”
It’s a bit late so may have missed something, hope this gives you a pointer however.
On another note I wanted at some point to modify the tf_aws_vpc community module to use this function to work out subnets, however not sure if this would be easy work.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com<mailto:terraform-too...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/54baf266-d632-4a2f-bdfa-1c2c2e9e8506%40googlegroups.com<https://groups.google.com/d/msgid/terraform-tool/54baf266-d632-4a2f-bdfa-1c2c2e9e8506%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/2a6395d2-297b-484e-ae1a-316e0877dbcd%40googlegroups.com.