cloud-foundation-fabric/factories/subnets
Simone Ruffilli 7b07d1fb8d
Update README.md
2021-12-07 09:00:04 +01:00
..
README.md Update README.md 2021-12-07 09:00:04 +01:00
main.tf Resource factories 2021-10-14 17:00:04 +02:00
outputs.tf Added subnet id and self_link to outputs (#377) 2021-12-04 20:01:22 +01:00
variables.tf Resource factories 2021-10-14 17:00:04 +02:00
versions.tf Use the same versions file everywhere, pin to tf 1.0+ provider 4.0+ (#355) 2021-11-03 15:05:43 +01:00

README.md

Google Cloud Resource Factories - VPC Subnets

This module implements a resource factory which allows the creation and management of subnets through properly formatted yaml files.

yaml configurations are stored on a well-defined folder structure, whose entry point can be customized, and which allows for simple grouping of subnets by Project > VPC.

Example

Terraform code

module "subnets" {
  source        = "./factories/subnets"
  config_folder = "subnets"
}
# tftest:skip

Configuration Structure

The directory structure implies the project and the VPC each subnet belongs to. Per the structure below, a subnet named subnet-a (after filename subnet-a.yaml) will be created on VPC vpc-alpha-one which belongs to project project-alpha.

Projects and VPCs should exist prior to running this module, or set as an explicit dependency to this module, leveraging depends_on.

└── subnets
    ├── project-alpha
    │   ├── vpc-alpha-one
    │   │   ├── subnet-a.yaml
    │   │   └── subnet-b.yaml
    │   └── vpc-alpha-two
    │       └── subnet-c.yaml  
    └── project-bravo
        └── vpc-bravo-one
            └── subnet-d.yaml

Subnet definition format and structure

region: europe-west1              # Region where the subnet will be creted
description: Sample description   # Description
ip_cidr_range: 10.0.0.0/24        # Primary IP range for the subnet
private_ip_google_access: false   # Opt- Enables PGA. Defaults to true
iam_users: ["foobar@example.com"] # Opt- Users to grant compute/networkUser to
iam_groups: ["lorem@example.com"] # Opt- Groups to grant compute/networkUser to
iam_service_accounts: ["foobar@project-id.iam.gserviceaccount.com"]         
                                  # Opt- SAs to grant compute/networkUser to
secondary_ip_ranges:              # Opt- List of secondary IP ranges
  - secondary-range-a: 192.168.0.0/24       
                                  # Secondary ranges in name: cidr format

Variables

name description type required default
config_folder Relative path of the folder containing the subnet configuration string

Outputs

name description sensitive
subnet Generated subnets