Skip to content

GoogleCloudPlatform/terraform-google-load-balanced-vms

Repository files navigation

Load balanced managed VMs

This module was generated from terraform-google-module-template, which by default generates a module that simply creates a GCS bucket. As the module develops, this README should be updated.

The resources/services/activations/deletions that this module will create/trigger are:

  • Instance Template
  • Managed Instance Group
  • Load Balancer

Tagline

Create a Managed Instance Group exposed by a HTTP Load Balancer.

Detailed

Create a virtual machine cluster with a load balancer to make the VMs globally available, and instantaneously manage traffic. You can choose whether to deploy your solution through the console directly or download as Terraform on GitHub to deploy later.

Architecture

  1. The user makes a request to the application, which is deployed on Compute Engine. The request first lands on Cloud Load Balancing.
  2. Cloud Load Balancing distributes traffic to the Compute Engine Managed Instance Group (MIG), which scales the number of instances based on traffic volume.

Documentation

Usage

Basic usage of this module is as follows:

module "load_balanced_vms" {
  source  = "terraform-google-modules/load-balanced-vms/google"
  version = "~> 0.4"

  project_id  = "<PROJECT ID>"
  region = "us-central1"
  zone = "us-central1-a"
  nodes = "3"
  deployment_name = "load-balanced-vms"
}

Open in Cloud Shell

An other way of using this Terraform solution is with DeployStack, which will ask for setting options in Cloud Shell.

Open in Cloud Shell

Functional examples are included in the examples directory.

Inputs

Name Description Type Default Required
deployment_name The name of this particular deployment, will get added as a prefix to most resources. string "load-balanced-vms" no
enable_apis Whether or not to enable underlying apis in this solution. . string true no
labels A map of labels to apply to contained resources. map(string)
{
"load-balanced-vms": true
}
no
network_id VPC network to deploy VMs in. A VPC will be created if not specified. string "" no
network_project_id Shared VPC host project ID if a Shared VPC is provided via network_id. string "" no
nodes The number of nodes in the managed instance group string n/a yes
project_id The project ID to deploy to string n/a yes
region The Compute Region to deploy to string n/a yes
subnet_self_link Subnetwork to deploy VMs in. A Subnetwork will be created if not specified. string "" no
zone The Compute Zone to deploy to string n/a yes

Outputs

Name Description
console_page_for_load_balancer The url of the load balancer page in console
load_balancer_endpoint The url of the front end which we want to surface to the user
neos_tutorial_url The URL to launch the in-console tutorial for the Load balanced managed VMs solution

Requirements

These sections describe requirements for using this module.

Software

The following dependencies must be available:

Service Account

A service account with the following roles must be used to provision the resources of this module:

  • Compute Admin: roles/compute.admin

The Project Factory module and the IAM module may be used in combination to provision a service account with the necessary roles applied.

APIs

A project with the following APIs enabled must be used to host the resources of this module:

  • Google Cloud Compute API: compute.googleapis.com

The Project Factory module can be used to provision a project with the necessary APIs enabled.

Contributing

Refer to the contribution guidelines for information on contributing to this module.

This is not an official Google product