Slide 17
Slide 17 text
Example
locals {
subnets = cidrsubnets("10.0.0.0/16", 8, 8, 8, 8, 8,
8, 8, 8, 8)
}
module "vpc" {
## omitted for clarity
private_subnets = slice(local.subnets, 0, 3)
public_subnets = slice(local.subnets, 3, 6)
}
def test_vpc_subnets_have_correct_netmask(vpc_subnets):
wrong_subnets = [subnet['values'].get('id') for subnet in
vpc_subnets if not
subnet['values'].get('cidr_block').endswith('/24')]
assert len(wrong_subnets) == 0, "subnets {} should have /24
CIDR block".format(wrong_subnets)
This function should create subnets with a /24 subnet mask.