Skip to content

googleDeploymentManagerDeployment

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).

Example Usage - Deployment Manager Deployment Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.deploymentManagerDeployment.DeploymentManagerDeployment(
  this,
  "deployment",
  {
    labels: [
      {
        key: "foo",
        value: "bar",
      },
    ],
    name: "my-deployment",
    target: [
      {
        config: [
          {
            content: '${file("path/to/config.yml")}',
          },
        ],
      },
    ],
  }
);

Example Usage - Deployment Manager Deployment Imports

resource "google_deployment_manager_deployment" "deployment" {
  name = "my-deployment"
  target {
    config {
      content = <<EOF
imports:
- path: service_account.jinja
- path: vm.jinja

resources:
- name: &SA_NAME my-vm-account
  type: service_account.jinja
- name: my-vm
  type: vm.jinja
  properties:
    serviceAccountId: *SA_NAME
EOF

    imports {
      name = "vm.jinja"
      content = file("path/to/vm.jinja")
    }

    imports {
      name = "service_account.jinja"
      content = file("path/to/service_account.jinja")
    }
  }
}

Argument Reference

The following arguments are supported:

  • name - (Required) Unique name for the deployment

  • target - (Required) Parameters that define your deployment, including the deployment configuration and relevant templates. Structure is documented below.

The target block supports:

  • config - (Required) The root configuration file to use for this deployment. Structure is documented below.

  • imports - (Optional) Specifies import files for this configuration. This can be used to import templates or other files. For example, you might import a text file in order to use the file in a template. Structure is documented below.

The config block supports:

  • content - (Required) The full YAML contents of your configuration file.

The imports block supports:

  • content - (Optional) The full contents of the template that you want to import.

  • name - (Optional) The name of the template to import, as declared in the YAML configuration.


  • description - (Optional) Optional user-provided description of deployment.

  • labels - (Optional) Key-value pairs to apply to this labels. Structure is documented below.

  • createPolicy - (Optional) Set the policy to use for creating new resources. Only used on create and update. Valid values are createOrAcquire (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 is createOrAcquire. Possible values are acquire and createOrAcquire.

  • deletePolicy - (Optional) 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 is delete. Possible values are abandon and delete.

  • preview - (Optional) 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.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

The labels block supports:

  • key - (Optional) Key for label.

  • value - (Optional) Value of label.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format projects/{{project}}/deployments/{{name}}

  • deploymentId - Unique identifier for deployment. Output only.

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

  • selfLink - Output only. Server defined URL for the resource.

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 60 minutes.
  • update - Default is 60 minutes.
  • delete - Default is 60 minutes.

Import

Deployment can be imported using any of these accepted formats:

$ terraform import google_deployment_manager_deployment.default projects/{{project}}/deployments/{{name}}
$ terraform import google_deployment_manager_deployment.default {{project}}/{{name}}
$ terraform import google_deployment_manager_deployment.default {{name}}

User Project Overrides

This resource supports User Project Overrides.