Google Cloud Deployment Manager Deployment

This page shows how to write Terraform for Cloud Deployment Manager Deployment and write them securely.

google_deployment_manager_deployment (Terraform)

The Deployment in Cloud Deployment Manager can be configured in Terraform with the resource name google_deployment_manager_deployment. The following sections describe 2 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L7
resource "google_deployment_manager_deployment" "this" {
  create_policy = var.create_policy
  delete_policy = var.delete_policy
  description   = var.description
  name          = var.name
  preview       = var.preview
main.tf#L1
resource "google_deployment_manager_deployment" "deployment" {
  count         = length(var.deployment)
  name          = lookup(var.deployment[count.index], "name")
  description   = lookup(var.deployment[count.index], "description", null)
  create_policy = lookup(var.deployment[count.index], "create_policy", null)
  delete_policy = lookup(var.deployment[count.index], "delete_policy", null)

Review your Terraform file for Google best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Set the policy to use for creating new resources. Only used on create and update. Valid values are 'CREATE_OR_ACQUIRE' (default) or 'ACQUIRE'. If set to 'ACQUIRE' and resources do not already exist, the deployment will fail. Note that updating this field does not actually affect the deployment, just how it is updated. Default value: "CREATE_OR_ACQUIRE" Possible values: ["ACQUIRE", "CREATE_OR_ACQUIRE"]

Set the policy to use for deleting new resources on update/delete. Valid values are 'DELETE' (default) or 'ABANDON'. If 'DELETE', resource is deleted after removal from Deployment Manager. If 'ABANDON', the resource is only removed from Deployment Manager and is not actually deleted. Note that updating this field does not actually change the deployment, just how it is updated. Default value: "DELETE" Possible values: ["ABANDON", "DELETE"]

Unique identifier for deployment. Output only.

Optional user-provided description of deployment.

  • id optional computed - string
  • manifest optional computed - string

Output only. URL of the manifest representing the last manifest that was successfully deployed.

Unique name for the deployment

If set to true, a deployment is created with "shell" resources that are not actually instantiated. This allows you to preview a deployment. It can be updated to false to actually deploy with real resources. ~>NOTE: Deployment Manager does not allow update of a deployment in preview (unless updating to preview=false). Thus, Terraform will force-recreate deployments if either preview is updated to true or if other fields are updated while preview is true.

Output only. Server defined URL for the resource.

  • labels set block
    • key optional - string

    Key for label.

    Value of label.

  • target list block
    • config list block

      The full YAML contents of your configuration file.

    • imports list block

      The full contents of the template that you want to import.

      The name of the template to import, as declared in the YAML configuration.

  • timeouts single block

Explanation in Terraform Registry

A collection of resources that are deployed and managed together using a configuration file

Warning: Deployment Manager shares similar behavior with Terraform as both products manage GCP resource lifecycle and state. This Terraform resource is intended only to manage a Deployment resource, and attempts to manage the Deployment's resources in Terraform as well will likely result in errors or unexpected behavior as the two tools fight over ownership. We strongly discourage doing so unless you are an experienced user of both tools. In addition, due to limitations of the API, Terraform will treat deployments in preview as recreate-only for any update operation other than actually deploying an in-preview deployment (i.e. preview=true to preview=false).

Frequently asked questions

What is Google Cloud Deployment Manager Deployment?

Google Cloud Deployment Manager Deployment is a resource for Cloud Deployment Manager of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google Cloud Deployment Manager Deployment?

For Terraform, the niveklabs/google and mikamakusa/terraform source code examples are useful. See the Terraform Example section for further details.

security-icon

Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.