✏️

Cloud Deployment Manager Cheatsheet

Glossary

Configuration - describes all the resources you want for a single deployment. YAML. Must contain resources:.

Example

Template - optional reusable individual building blocks of a Configuration. Python or Jinja2.

Example: Jinja2
Example: Python

Resource - a single API resource, such as Compute Engine instance or a Cloud SQL instance. Each Resource must contain name, type and properties.

Type - single API resource, known as a base type (list of supported base types), or a template (aka “Composite type”).

Manifest - a record that contains the original fully expanded Configuration you provided.

Deployment - collection of resources deployed based on provided Configuration

Schema - defines a set of rules that a Configuration file must meet if it wants to use a particular Template. Structure.

Example

Outputs - key/value pairs that you can define in the Configuration or Templates that will show up in the Manifest after deployment. Example: IP address of a deployed VM.

Property - a static variable that you can use throughout Templates.

Reference - dynamic variables that are not defined until a Resource is created.

Example

Preview - shows resources that Deployment Manager would create if you create or update the Deployment. More.

Update Policy - how your resources are updated when you update the Deployment. More.

Best practices

Do not modify resources deployed with Deployment Manager using cloud console or gcloud. Instead, update the Deployment.

While it’s possible to include secret credentials in Configurations and Templates, and Deployment Manager will attempt to redact them, it’s still better to avoid doing so.

While Jinja2 is simpler and cleaner, it’s still recommended to use Python templates due to better flexibility. It looks ugly though... 🤢

Structure your Configuration file to use only one type, and use a top-level template to call all other templates... 🤮

Use labels. Duh...

Create many small Deployments, not one huge Deployment.

For large deployments arrange configs in a hierarchical structure in multiple files rather than single config per deployment.

Workflow

  1. Create config file. All static configs will be here.
  2. Create top-level template file, reference it in the config file.
  3. Open the Resources Types reference and map the services you need in the right order.
  4. Using the Resources Types reference, go to each of your deployment resources one by one and write static configuration for each of them.
  5. Run gcloud deployment-manager deployments create/update my-deployment --config deployment/deployment_config.yaml --preview to validate the deployment.
  6. Run gcloud deployment-manager deployments update my-deployment to release preview.
  7. Run gcloud deployment-manager deployments cancel-preview my-deployment to cancel preview.
  8. ...

Production-ready sample templates

Further reading:

Conclusion

Don’t use it