Question

Difficulty: HardDeploying Infrastructure using Deployment Manager or Terraform

An enterprise platform team is developing modular Google Cloud Deployment Manager templates written in Python to dynamically calculate persistent disk allocations and VM custom metadata based on environment variables. A cloud engineer must first inspect the fully expanded resource manifests and dry-run state without actually provisioning infrastructure in Google Cloud. Once the generated configuration is audited and approved, the engineer must commit and provision the resources. Which TWO steps should the cloud engineer take to execute this deployment lifecycle?

  1. Execute `gcloud deployment-manager deployments create prod-stack --config=config.yaml --preview` to stage and inspect the expanded resource manifest.Answer
  2. Execute `gcloud deployment-manager deployments update prod-stack` after reviewing the preview state to instantiate the planned resources.Answer
  3. C
    Enable the Deployment Manager API exclusively in the organization's Shared VPC host project and run `gcloud deployment-manager deployments create prod-stack --config=config.yaml --dry-run`.
  4. D
    Execute `gcloud deployment-manager deployments preview prod-stack --config=config.yaml` followed by `gcloud deployment-manager deployments commit prod-stack` to finalize provisioning.

Answer

The cloud engineer should first execute the deployment create command with the `--preview` flag to generate and inspect the template expansion, and then execute the deployment update command on the existing preview deployment to commit and provision the infrastructure.
In Google Cloud Deployment Manager, dry-running template expansion requires using the `--preview` flag in conjunction with the `deployments create` or `deployments update` command. This compiles the Python/Jinja templates into a expanded manifest and saves the deployment in a PREVIEW state. Once the manifest is audited, running `gcloud deployment-manager deployments update [DEPLOYMENT_NAME]` without specifying a new config file commits the previewed deployment and provisions the resources.

Step-by-Step Solution

1
Use `gcloud deployment-manager deployments create [DEPLOYMENT_NAME] --config=[CONFIG_FILE] --preview`
Deployment Manager parses the configuration files, expands Jinja2 or Python templates, and places the deployment in a PREVIEW state without creating or modifying actual cloud resources.
This allows engineers to inspect the exact manifest and resource parameters before making changes in GCP.
2
Auditing the generated manifest
The engineer verifies that dynamic logic in the Python templates produces the expected disk sizes and VM metadata.
Validates parameterization and resource properties before real resource billing or network creation begins.
3
Execute `gcloud deployment-manager deployments update [DEPLOYMENT_NAME]`
Deployment Manager transitions the deployment from PREVIEW state to active deployment, creating all defined GCP resources.
Running update on a previewed deployment commits the previewed state without requiring the config file parameter again.

Key Concept

Deployment Manager Preview and Update Lifecycle
Rate this question