Course contentsShow
← Cloud and Infrastructure
Lesson 950 of 2,98918. Google Cloud Deployment ManagerFree lesson

Template Imports and Organization

Import external templates and organize configurations across multiple files.

Template Imports and Organization

Important Note: Google Cloud Deployment Manager reached end of support on March 31, 2026. For all new infrastructure work, you should use Google Cloud Infrastructure Manager or Terraform. The concepts and syntax discussed below are provided strictly as legacy reference for understanding and maintaining existing Deployment Manager configurations.

What you'll learn: How large legacy Deployment Manager configurations were split into reusable, maintainable pieces across multiple files.

The Problem with Monolithic Templates

As infrastructure configurations grew, cramming everything into a single YAML file became unwieldy and error-prone. To solve this, Deployment Manager allowed administrators to break configurations into separate template files. This approach made code easier to read and mirrored real-world team boundaries, where different specialists handled different components (e.g., networking vs. compute).

Importing External Templates in Legacy Deployments

Deployment Manager used an imports section within the main configuration to bring in external template files. This functioned much like including libraries in programming software—you referenced external files containing reusable resource definitions or template logic.

# Legacy Reference Only
imports:
  - path: network-template.yaml
  - path: compute-template.yaml

resources:
  - name: my-network
    type: network-template.yaml
  - name: my-instance
    type: compute-template.yaml

Each imported file acted as a custom type that could be referenced in the resources section, just like referencing a built-in GCP resource type.

Organization Patterns

When reviewing existing Deployment Manager environments, you will typically see these organizational patterns:

  • Separation by function: Individual template files exist for logical components, such as network-template.yaml for networking and vm-template.yaml for compute resources.
  • Relative paths: Imported files were resolved relative to the main configuration file's location. They are often grouped into dedicated subdirectories to maintain clarity.
  • Reusability: A well-organized template was often imported into multiple legacy deployments, establishing a single source of truth and ensuring consistency across environments.

Example Directory Structure

When maintaining or migrating older infrastructure, you may encounter structures similar to this:

my-deployment/
  ├── config.yaml           # Main configuration
  ├── templates/
      ├── network.yaml      # Network resources
      └── compute.yaml      # VM resources

Key Takeaway: Legacy Deployment Manager environments utilized template imports to break monolithic configurations into modular, reusable files. When maintaining these systems, understanding this file structure helps you trace resource definitions effectively as you prepare to migrate them to modern tools like Terraform or Infrastructure Manager.