Single VM stack creates an individual VM with a smart default, but also the ability to customize the Virtual Machine. It uses:
- Compute - VMs - Compute Engine
Example sets up a simple single virtual machine, and allows you to ssh into it.
Get Started
Click on the following link to a copy of the source code in Cloud Shell. Once there, a single command will spin up a working copy of the application in your project..
Single VM components
The Single VM architecture makes use of one key product. The following highlights that product, along with more information, including links to related videos, product documentation, and interactive walkthroughs.Scripts
The install script uses an executable written in go
and Terraform CLI tools to
take an empty project and install the application in it. The output should be a
working application and a url for the load balancing IP address.
./main.tf
Enable Services
Google Cloud Services are disabled in a project by default. In order to use any of the solutions here, we have to activate the following:
- Compute Engine — virtual machines and networking
variable "gcp_service_list" {
description = "The list of apis necessary for the project"
type = list(string)
default = [
"compute.googleapis.com",
]
}
resource "google_project_service" "all" {
for_each = toset(var.gcp_service_list)
project = var.project_number
service = each.key
disable_dependent_services = false
disable_on_destroy = false
}
Create a virtual machine
Creates a VM.
resource "google_compute_instance" "instance" {
name = var.instance-name
machine_type = var.instance-machine-type
zone = var.zone
project = var.project_id
tags = var.instance-tags
boot_disk {
auto_delete = true
device_name = var.instance-name
initialize_params {
image = var.instance-image
size = var.instance-disksize
type = var.instance-disktype
}
}
network_interface {
network = "default"
access_config {
// Ephemeral public IP
}
}
depends_on = [google_project_service.all]
}
Conclusion
Once run, you should now have a single VM. You can ssh into it and configure it however you'd like. Additionally you should have all of the code to modify or extend this solution to fit your environment.