You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Cloud Deployment Manager
Cloud Deployment Manager
Google Cloud Deployment Manager is Google's native Infrastructure as Code (IaC) service. It allows you to define, deploy, and manage Google Cloud resources using declarative YAML configuration files and templates. Deployment Manager treats infrastructure as repeatable, version-controlled code — eliminating manual resource creation and reducing configuration drift.
What Is Deployment Manager?
Deployment Manager is a fully managed service that automates the creation and management of Google Cloud resources. You describe the desired state of your infrastructure in configuration files, and Deployment Manager creates, updates, or deletes resources to match that state.
Key Characteristics
| Characteristic | Description |
|---|---|
| Declarative | Define what you want, not how to create it |
| Repeatable | Deploy the same configuration to multiple projects or environments |
| Idempotent | Running the same deployment twice produces the same result |
| Preview | Preview changes before applying them |
| Parallel | Creates independent resources in parallel for faster deployments |
| Integrated | Native to GCP — no additional tools to install |
Core Concepts
Configurations
A configuration is a YAML file that describes the resources you want to create. Each resource has a name, a type, and properties:
resources:
- name: my-vm
type: compute.v1.instance
properties:
zone: europe-west1-b
machineType: zones/europe-west1-b/machineTypes/e2-medium
disks:
- boot: true
autoDelete: true
initializeParams:
sourceImage: projects/debian-cloud/global/images/family/debian-11
networkInterfaces:
- network: global/networks/default
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
Resource Types
Deployment Manager supports all Google Cloud resource types. Each type corresponds to a GCP API resource:
| Type | Example |
|---|---|
| Compute | compute.v1.instance, compute.v1.network |
| Storage | storage.v1.bucket |
| SQL | sqladmin.v1beta4.instance |
| Pub/Sub | pubsub.v1.topic, pubsub.v1.subscription |
| IAM | iam.v1.serviceAccount |
| GKE | container.v1.cluster |
Deployments
A deployment is a collection of resources managed together. When you create a deployment, Deployment Manager provisions all the resources defined in the configuration:
# Create a deployment
gcloud deployment-manager deployments create my-deployment \
--config=config.yaml
# Update a deployment
gcloud deployment-manager deployments update my-deployment \
--config=config-v2.yaml
# Preview changes before applying
gcloud deployment-manager deployments update my-deployment \
--config=config-v2.yaml \
--preview
# Apply the previewed changes
gcloud deployment-manager deployments update my-deployment
# Delete a deployment (deletes all managed resources)
gcloud deployment-manager deployments delete my-deployment
Templates
Templates make configurations reusable and parameterisable. Deployment Manager supports two template formats:
Jinja2 Templates
{# vm-template.jinja #}
resources:
- name: {{ env["name"] }}
type: compute.v1.instance
properties:
zone: {{ properties["zone"] }}
machineType: zones/{{ properties["zone"] }}/machineTypes/{{ properties["machineType"] }}
disks:
- boot: true
autoDelete: true
initializeParams:
sourceImage: {{ properties["sourceImage"] }}
networkInterfaces:
- network: global/networks/default
Python Templates
Python templates provide more flexibility with logic, loops, and conditionals:
# vm-template.py
def GenerateConfig(context):
resources = []
for i in range(context.properties['count']):
resources.append({
'name': f'{context.env["name"]}-{i}',
'type': 'compute.v1.instance',
'properties': {
'zone': context.properties['zone'],
'machineType': f'zones/{context.properties["zone"]}/machineTypes/{context.properties["machineType"]}',
'disks': [{
'boot': True,
'autoDelete': True,
'initializeParams': {
'sourceImage': context.properties['sourceImage'],
},
}],
'networkInterfaces': [{
'network': 'global/networks/default',
}],
},
})
return {'resources': resources}
Using Templates
Reference templates from your configuration file:
imports:
- path: vm-template.jinja
resources:
- name: web-server
type: vm-template.jinja
properties:
zone: europe-west1-b
machineType: e2-medium
sourceImage: projects/debian-cloud/global/images/family/debian-11
Schema Files
Schema files validate template properties and provide documentation:
# vm-template.jinja.schema
info:
title: VM Instance Template
description: Creates a Compute Engine VM instance
required:
- zone
- machineType
- sourceImage
properties:
zone:
type: string
description: The GCP zone for the instance
machineType:
type: string
description: The machine type (e.g., e2-medium)
default: e2-small
sourceImage:
type: string
description: The source image for the boot disk
Managing Dependencies
Deployment Manager automatically detects dependencies between resources. You can also define explicit dependencies using the metadata.dependsOn field:
resources:
- name: my-network
type: compute.v1.network
properties:
autoCreateSubnetworks: false
- name: my-subnet
type: compute.v1.subnetwork
properties:
network: $(ref.my-network.selfLink)
ipCidrRange: 10.0.0.0/24
region: europe-west1
- name: my-vm
type: compute.v1.instance
metadata:
dependsOn:
- my-subnet
properties:
zone: europe-west1-b
machineType: zones/europe-west1-b/machineTypes/e2-medium
networkInterfaces:
- subnetwork: $(ref.my-subnet.selfLink)
The $(ref.resource-name.property) syntax creates references between resources, which also establishes implicit dependencies.
Limitations and Considerations
| Limitation | Description |
|---|---|
| GCP only | Only manages Google Cloud resources |
| State management | State is managed by the service — no remote state configuration |
| No import | Cannot import existing resources into a deployment |
| Template language | Limited to Jinja2 and Python (no HCL, TypeScript, etc.) |
| Community | Smaller community compared to Terraform |
Summary
Cloud Deployment Manager is Google Cloud's native IaC tool for defining and managing infrastructure as code. It uses declarative YAML configurations with Jinja2 or Python templates for reusability. While it integrates seamlessly with GCP, its scope is limited to Google Cloud resources. For multi-cloud environments or teams already using Terraform, Deployment Manager may not be the best fit — but for GCP-only projects, it provides a straightforward, fully managed IaC experience with no additional tooling required. In the next lesson, we will explore Terraform on GCP, which offers multi-cloud support and a larger ecosystem.