Skip to content

oneanupam/terraform-google-vpc

Repository files navigation

Terraform VPC Module

This module creates a VPC network resource on Google Cloud Platform. Currently there are no sub-modules available for deploying any other networking resource except VPC.

Prerequisites

Below prerequisites must be fulfilled for successful execution of terraform concept code sets.

Software Requirement

Resources in this repository are meant to use with Terraform 1.3.6 (check the terraform version using: terraform version). If you don't have the compatible version, download it from official Terraform repository.

Note: See Installation-Guide on how to install Terraform.

API Requirement

In order to deploy the VPC using this module, you must activate the Compute Engine API on the project.

  • Compute Engine API - compute.googleapis.com

Example Usage

module "example-vpc" {
  source = "anupam-sy/vpc/google"

  vpc_name                        = "<VPC NAME>"
  project_id                      = "<PROJECT ID>"
  routing_mode                    = "GLOBAL"
  auto_create_subnetworks         = false
  delete_default_routes_on_create = false
}

Then perform the following commands on the root folder:

  • [Required] terraform init # To initialize the terraform working directory.
  • [Optional] terraform validate # To validate the terraform configuration.
  • [Optional] terraform fmt # To format the terraform configuration to a canonical format and style.
  • [Optional] terraform plan # To create an execution plan for terraform configuration files.
  • [Required] terraform apply -auto-approve # To execute the actions proposed in a terraform plan to create, update, or destroy infrastructure.
  • [Optional] terraform destroy -auto-approve # To destroy the created infrastructure. Specific resources can be destroyed using resource targeting.

Testing

Integration testing for terraform modules can be done using available tools. This terraform module uses Kitchen-Terraform. Kitchen-Terraform integrates Test Kitchen with Terraform, enabling you to write tests using InSpec to validate your infrastructure.

Tools Requirement

  • Kitchen-Terraform: A Test Kitchen plugin for Terraform that allows you to test your Terraform configurations.
  • Test Kitchen: An integration tool for developing and testing infrastructure code.
  • InSpec: A testing framework used to write tests to verify the state of your infrastructure.
  • Ruby: Kitchen-Terraform and Test Kitchen are Ruby-based, so you’ll need Ruby installed.
  • Bundler: A dependency manager for Ruby projects to manage and install the required gems.

Tests Execution

Run kitchen tests commands as per Test Kitchen workflow to test the terraform modules to esnure that they are working as expected.

  • bundle exec kitchen create # Initialises terraform state and

  • bundle exec kitchen converge # Creates the required resources

  • bundle exec kitchen verify # Tests the created infrastructure

  • bundle exec kitchen destroy # Destroys the created infrastructure

  • bundle exec kitchen test # You can club the complete testing lifecycle commands into a single command.

About

This module deploys a VPC network on google cloud.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •