You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Instance templates and instance groups are foundational building blocks for scalable, resilient architectures on Compute Engine. Instance templates define a VM configuration that can be reused, while instance groups manage collections of VM instances as a single unit.
An instance template is a resource that defines the properties of a VM instance — machine type, boot disk image, network configuration, labels, metadata, service account, and more. Templates are immutable — once created, they cannot be modified. To change a configuration, you create a new template.
gcloud compute instance-templates create web-template-v1 \
--machine-type=e2-standard-2 \
--image-family=debian-12 \
--image-project=debian-cloud \
--boot-disk-size=20GB \
--boot-disk-type=pd-balanced \
--tags=http-server,https-server \
--metadata=startup-script='#!/bin/bash
apt-get update && apt-get install -y nginx' \
--service-account=web-sa@my-project.iam.gserviceaccount.com \
--scopes=cloud-platform \
--labels=app=web,env=production
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.