Creating subnets
GCP VPCs are organized with subnets, which enable the deployment of compute workloads in specific regions. Subnets also allow us to segment our virtual network into distinct routing and security domains, giving us fine-grained control over routing and security policies. This approach ensures that each subnet can have tailored behavior to meet specific requirements.
In this recipe, you will define and provision subnets within the GCP cloud using the google.cloud.gcp_compute_subnet module:
- Update the
group_vars/gcp_vpc.ymlfile with the subnets’ data, as shown here:root@cookbook-lab:~/cookbook-lab/chapters/ch10# vi group_vars/gcp_vpc.yml ... omitted output ... region: us-central1 subnets: - name: usc-web cidr: 192.0.1.0/24 - name: usc-db cidr: 192.0.2.0/24 - name: usc-bastion ...