Deploying Resources with Google Cloud Deployment Manager

1 hour
  • 5 Learning Objectives

About this Hands-on Lab

In this hands-on lab, we will introduce ourselves to working with Google Cloud Deployment Manager. We will start with a simple single-VM deployment, move on to a more complex deployment with multiple dependencies, and finish by deploying a group of imported template configurations in a single deployment.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Download configuration files used for this lab

We will perform the majority of our activities in Cloud Shell.

  • From the web console, open Cloud Shell from the top-right
  • Download the configuration files we will use for this lab by copy/pasting the following command:

    gsutil -m cp -r gs://acg-gcp-labs-resources/deployment-manager-basic/* .

Note: The period at the end of the command is required.

Create your first single VM deployment

Before we create our first deployment, we must first edit our configuration file to reflect the current project.

  • From Cloud Shell, open the editor window by clicking the pencil icon in the top-right.

  • In the new window that appears, click on vm-web.yaml.

  • In the vm-web.yaml file, change all (YOUR_PROJECT) fields to reflect your current project ID. There should be 2 total.

  • Make sure the changes are saved by going to File – Save from the Cloud Shell Editor menu.

  • Back in the command prompt, deploy your first deployment by typing the following:

    gcloud deployment-manager deployments create single-vm --config vm-web.yaml
  • Once the deployment completes, go to the web console and verify that a Compute Engine instance has been created. You should be able to click the external IP address to view its website.

  • Still in the web console, delete your deployment by going to the top-left menu > Deployment Manager. Select your deployment and click DELETE.

Deploy complex deployment with dependencies

We are now going to deploy a more complex deployment manager configuration that requires deploying resources in a certain order.

  • Back in the Cloud Shell Editor, select the file dependencies.yaml.
  • Under the resource for server-1, scroll down to the NetworkInterfaces properties and notice that the network and subnetwork have a reference field supplied. This tells Deployment Manager that deploying this instance depends on other resources in the same deployment being created first. You can view other dependencies throughout the rest of the config file.
  • As before, change all the ‘(YOUR_PROJECT)’ fields to your current project ID. There are again two total, which you can find by the #CHANGE ME at the end of each affected line
    • Make sure the changes are saved by going to File – Save from the Cloud Shell Editor menu.
  • Back in command prompt, deploy this configuration by typing the following:

    gcloud deployment-manager deployments create vpcs --config dependencies.yaml
View deployment manifest and delete deployment

After deployment is complete, let’s view the manifest:

  • Still in command prompt, view details of your deployment:

    gcloud deployment-manager deployments describe vpcs
  • Look for a field in the form of manifest-(TIMESTAMP). Copy this field.

  • Type in the following to view the full manifest, supplying the manifest ID you copied above:

    gcloud deployment-manager manifests describe manifest-(TIMESTAMP) --deployment vpcs
  • You can also view the same manifests in the web console > Deployment Manager.

  • Delete your deployment using the following command:

    gcloud deployment-manager deployments delete vpcs
Create deployment with templates
  • In Cloud Shell, go to your templates directory:

    cd templates
  • In the Code Editor, view the template-config.yaml and the template .jinja files.

  • This time, we do not need to change the project ID because the template files are able to automatically resolve the current project ID.

  • Deploy your template-enabled configuration by typing:

    gcloud deployment-manager deployments create templates --config template-config.yaml
  • View results in web console, and attempt to open website via external IP.

  • Delete deployment using one of the methods above.

Additional Resources

Be sure to launch your lab in an incognito window (or other private web browser) to avoid issues with cached logins.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?