Terraform module for creating a VPC in GCP. Basic features:
- Based in Google's network module
- Configures 1 subnet
- IP CIDR defaults to
10.0.0.0/17
This module depends on you having GCP credentials of some kind. The module looks for a credential file in JSON format. You should export the following:
GOOGLE_APPLICATION_CREDENTIALS=/path/to/file.json
This repository defines a Terraform module, which you can use in your
code by adding a module
configuration and setting its source
parameter to URL of this repository. See the examples folder for guidance
Name | Version |
---|---|
terraform | >= 1.9.0 |
5.38.0 |
No providers.
Name | Source | Version |
---|---|---|
vpc | terraform-google-modules/network/google | 9.1.0 |
No resources.
Name | Description | Type | Default | Required |
---|---|---|---|---|
description | Subnet description | string |
"Deployed through Terraform." |
no |
ip_range_pods | The secondary ip range to use for pods | string |
"192.168.0.0/18" |
no |
ip_range_services | The secondary ip range to use for pods | string |
"192.168.64.0/18" |
no |
network_name | Name of the VPC. | string |
n/a | yes |
project_id | The project ID to host the VPC in | string |
n/a | yes |
range_name_pods | The range name for pods | string |
"kubernetes-pods" |
no |
range_name_services | The range name for services | string |
"kubernetes-services" |
no |
routing_mode | Routing mode. GLOBAL or REGIONAL | string |
"GLOBAL" |
no |
subnet_flow_logs | Whether to enable flow logging for the subnetwork. | string |
"true" |
no |
subnet_ip | Subnet IP CIDR. | string |
"10.0.0.0/17" |
no |
subnet_name | Name of the subnet. | string |
n/a | yes |
subnet_private_access | Enable private Google access | string |
"true" |
no |
subnet_region | Region subnet lives in. | string |
n/a | yes |
Name | Description |
---|---|
network_name | Name of the VPC. |
routing_mode | Routing mode. GLOBAL or REGIONAL |
subnet_ip | Subnet IP |
subnet_name | Name of the subnetwok. |
Use GitLab Flow.
- Create feature branches for features and fixes from default branch
- Merge only from PR with review
- After merging to default branch a release is drafted using a github action. Check the draft and publish if you and tests are happy
We recommend using asdf to manage your versions of Terrafom and Ruby.
brew install asdf
You can also install the latest version of terraform version via brew.
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
You should make sure that pre-commit hooks are installed to run the formater, linter, etc. Install and configure terraform pre-commit hooks as follows:
Install rependencies
brew bundle install
Install the pre-commit hook globally
DIR=~/.git-template
git config --global init.templateDir ${DIR}
pre-commit init-templatedir -t pre-commit ${DIR}
To run the hooks specified in .pre-commit-config.yaml
:
pre-commit run -a
This is only needed if running tests locally. The google-cloud-sdk is included in the Brewfile so it should now be installed
This repo includes a env.sh
file that where you set the path to the google credentials file, then use
source env.sh
and
deactivate
to set and uset the GOOGLE_APPLICATION_CREDENTIALS
variable.
The tests can be run locally with terraform test
after running terraform init
. You will need to supply org_id
, folder_id
, and billing_account
variables through terraform.tfvars
file. Please see terraform.tfvars.example
file for an example.
This project has three workflows enabled:
-
PR labeler: When opening a PR to default branch, a label is given assigned automatically according to the name of your feature branch. The labeler follows the follows rules in pr-labeler.yml
-
Release Drafter: When merging to master, a release is drafted using the Release-Drafter Action
-
terraform test
runs on PR, merge to main and releases.