cloud-foundation-fabric/modules/compute-vm
Ludovico Magnocavallo 409407ae7d
Refactor the onprem module (#55)
* move onprem to cos-container

* compute-vm: fix external addresses output

* folders-unit: update README

* update onprem module, add new fields to cos-container test instance

* coredns: process corefile as a template

* onprem: fixes

* modules/cos-container: rename to cloud-config-container infra/onprem: remove test output

* Update README.md

* update CHANGELOG for v1.1.0

* fix cloud config modules tests

* Update main.tf

* add container nginx module
2020-04-06 16:27:13 +02:00
..
README.md Merge development branch (#44) 2020-04-03 14:06:48 +02:00
instance_group.tf Merge development branch (#44) 2020-04-03 14:06:48 +02:00
main.tf Merge development branch (#44) 2020-04-03 14:06:48 +02:00
outputs.tf Refactor the onprem module (#55) 2020-04-06 16:27:13 +02:00
variables.tf Merge development branch (#44) 2020-04-03 14:06:48 +02:00

README.md

Google Compute Engine VM module

This module allows creating one or multiple instances or an instance template for a specific configuration. A service account is optionally created and assigned if not specified.

TODO

  • add examples for instance groups

Examples

Instance leveraging defaults

The simplest example leverages defaults for the boot disk image and size, and uses a service account created by the module. Multiple instances can be managed via the instance_count variable.

module "simple-vm-example" {
  source     = "../modules/compute-vm"
  project_id = "my-project"
  region     = "europe-west1"
  zone       = "europe-west1-b"
  name       = "test"
  network_interfaces = [{
    network    = local.network_self_link,
    subnetwork = local.subnet_self_link,
    nat        = false,
    addresses  = null
  }]
  service_account_create = true
  instance_count = 1
}

Instance template

This example shows how to use the module to manage an instance template that defines an additional attached disk for each instance, and overrides defaults for the boot disk image and service account.

module "debian-test" {
  source     = "../modules/compute-vm"
  project_id = "my-project"
  region     = "europe-west1"
  zone       = "europe-west1-b"
  name       = "test"
  network_interfaces = [{
    network    = local.network_self_link,
    subnetwork = local.subnet_self_link,
    nat        = false,
    addresses  = null
  }]
  instance_count = 1
  boot_disk      = {
    image = "projects/cos-cloud/global/images/family/cos-stable"
    type  = "pd-ssd"
    size  = 10
  }
  attached_disks = [
    { name = "disk-1", size = 10, image = null, options = null }
  ]
  service_account        = "vm-default@my-project.iam.gserviceaccount.com"
  use_instance_template  = true
}

Variables

name description type required default
name Instances base name. string
network_interfaces Network interfaces configuration. Use self links for Shared VPC, set addresses to null if not needed. list(object({...}))
project_id Project id. string
region Compute region. string
zone Compute zone. string
attached_disk_defaults Defaults for attached disks options. object({...}) ...
attached_disks Additional disks, if options is null defaults will be used in its place. list(object({...})) []
boot_disk Boot disk properties. object({...}) ...
group Instance group (for instance use). object({...}) null
group_manager Instance group manager (for template use). object({...}) null
hostname Instance FQDN name. string null
instance_count Number of instances to create (only for non-template usage). number 1
instance_type Instance type. string f1-micro
labels Instance labels. map(string) {}
metadata Instance metadata. map(string) {}
min_cpu_platform Minimum CPU platform. string null
options Instance options. object({...}) ...
scratch_disks Scratch disks configuration. object({...}) ...
service_account Service account email. Unused if service account is auto-created. string null
service_account_create Auto-create service account. bool false
service_account_scopes Scopes applied to service account. list(string) []
tags Instance tags. list(string) []
use_instance_template Create instance template instead of instances. bool false

Outputs

name description sensitive
external_ips Instance main interface external IP addresses.
group Instance group resource.
group_manager Instance group resource.
instances Instance resources.
internal_ips Instance main interface internal IP addresses.
names Instance names.
self_links Instance self links.
service_account Service account resource.
service_account_email Service account email.
service_account_iam_email Service account email.
template Template resource.
template_name Template name.

TODO

  • add support for instance groups