Manage Google Cloud resources as a deployment
You can use Google Cloud Deployment Manager to create a set of Google Cloud resources and manage them as a unit, called a deployment. For example, if your team's development environment needs two virtual machines (VMs) and a BigQuery database, you can define these resources in a configuration file, and use Deployment Manager to create, change, or delete these resources. You can make the configuration file part of your team's code repository, so that anyone can create the same environment with consistent results.
In this tutorial, you'll use Google Cloud Deployment Manager to create a virtual machine (VM) instance. You'll define the VM in a basic configuration file, and use that configuration file to create a deployment.
To complete this tutorial, you must be comfortable running commands in a Linux, macOS, or Windows terminal.
For an interactive version of this tutorial, open it in Cloud Shell, where you can edit the sample configuration and deploy your resources without installing anything on your workstation. If you want to follow the tutorial on your own computer, skip to the next section.
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Deployment Manager and Compute Engine APIs.
- On your workstation, install the Google Cloud CLI.
- Configure the Google Cloud CLI to use your project. In the following command, replace
[MY_PROJECT]
with your project ID:gcloud config set project [MY_PROJECT]
Define your resources
You describe your resources in a configuration file, which is written in the YAML syntax.
Copy the sample configuration below, and paste it into a text editor.
This basic configuration file describes a deployment that contains one virtual machine instance with the following properties:
- Machine type:
f1-micro
- Image family:
debian-9
- Zone:
us-central1-f
- Root persistent disk:
boot
- A randomly assigned external IP address
- Machine type:
Replace all instances of
[MY_PROJECT]
with your project ID.Save the file as
vm.yaml
.
Deploy the resources
To deploy your resources, use the Google Cloud CLI to create a new deployment, using your configuration file:
gcloud deployment-manager deployments create quickstart-deployment --config vm.yaml
If the deployment is successful, you receive a message similar to the following example:
Create operation operation-1432319707382-516afeb5d00f1-b864f0e7-b7103978 completed successfully. NAME TYPE STATE ERRORS quickstart-deployment compute.v1.instance COMPLETED -
You now have your first deployment!
Check on your new deployment
To check the status of the deployment, run the following command:
gcloud deployment-manager deployments describe quickstart-deployment
You see a description of the deployment, including its start and end time, the resources created, and any warnings or errors:
fingerprint: xmVVeTtPq-5rr8F-vWFlrg== id: '54660732508021769' insertTime: '2016-03-09T04:45:26.032-08:00' manifest: https://www.googleapis.com/deploymentmanager/v2/projects/myproject/global/deployments/my-first-deployment/manifests/manifest-1457527526037 name: quickstart-deployment operation: endTime: '2016-03-09T04:46:19.480-08:00' id: '8993923014899639305' kind: deploymentmanager#operation name: operation-1457527525951-52d9d126f4618-f1ca6e72-3404bd3b operationType: insert progress: 100 startTime: '2016-03-09T04:45:27.275-08:00' status: DONE ... resources: NAME TYPE STATE ERRORS quickstart-deployment-vm compute.v1.instance COMPLETED -
Review your resources
After you have created the deployment, you can review your resources in Google Cloud console.
To see a list of your deployments, open the Deployment Manager page.
To see the resources in the deployment, click quickstart-deployment. The deployment overview opens, with information about the deployment, and the resources that are part of the deployment.
To see information about your VM, click quickstart-deployment-vm.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
gcloud deployment-manager deployments delete quickstart-deployment
Type y
at the prompt:
The following deployments will be deleted: - quickstart-deployment Do you want to continue (y/N)?
The deployment and the resources you created are permanently deleted.
What's next
- Learn about best practices for creating deployments by following the Step-by-step guide to Deployment Manager.
- Learn about Deployment Manager concepts.
- See the resources that you can create and manage in your deployments.