The fingerprint of the deployment is ulPDrJON8E5ySHKC5fcukw==
Waiting for create [operation-1492785372594-54dae2ddbff50-58d45d53-12d483cf]...done.
Create operation operation-1492785372594-54dae2ddbff50-58d45d53-12d483cf completed successfully.
NAME TYPE STATE ERRORS INTENT
datadisk-example compute.v1.disk IN_PREVIEW [] CREATE_OR_ACQUIRE
vm-example compute.v1.instance IN_PREVIEW [] CREATE_OR_ACQUIRE
API
在 API 中,使用 insert() 方法,并在请求正文中包含 target 和 name 字段以及 preview=true 查询参数。在 target 字段中提供您的配置。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-03。"],[[["\u003cp\u003ePreviewing a configuration allows you to see the resources that Deployment Manager would create without actually instantiating them.\u003c/p\u003e\n"],["\u003cp\u003eYou can preview a configuration using the \u003ccode\u003epreview\u003c/code\u003e query parameter in an \u003ccode\u003einsert()\u003c/code\u003e request or with the \u003ccode\u003e--preview\u003c/code\u003e flag using the \u003ccode\u003egcloud\u003c/code\u003e command-line tool.\u003c/p\u003e\n"],["\u003cp\u003eAfter previewing a deployment, you can either commit the configuration by performing an update, cancel the preview and delete the deployment, or perform another preview with updated configuration files.\u003c/p\u003e\n"],["\u003cp\u003ePerforming multiple previews involves using the \u003ccode\u003eupdate\u003c/code\u003e command with the \u003ccode\u003e--preview\u003c/code\u003e flag or making a \u003ccode\u003ePUT()\u003c/code\u003e request with the \u003ccode\u003epreview=true\u003c/code\u003e query parameter to update an existing deployment.\u003c/p\u003e\n"],["\u003cp\u003eWhile a deployment is in preview mode, you cannot deploy a new configuration to the same deployment; you must cancel the preview before updating with a new configuration.\u003c/p\u003e\n"]]],[],null,["# Previewing a configuration\n\nThis page describes how to preview a configuration file before creating a\ndeployment. To learn more about configurations, read [Configurations Overview](/deployment-manager/docs/configuration).\n\nAfter you have [written a configuration file](/deployment-manager/docs/configuration/create-basic-configuration),\nyou can preview the configuration before you create a deployment. Previewing\na configuration lets you see the resources that Deployment Manager would create\nbut does not actually instantiate any actual resources. The\nDeployment Manager service previews the configuration by:\n\n1. Expanding the full configuration, including any templates.\n2. Creating a deployment and \"shell\" resources.\n\nYou can preview your configuration by using the `preview` query parameter when\nmaking an [`insert()`](/deployment-manager/docs/reference/latest/deployments/insert)\nrequest.\n\nBefore you begin\n----------------\n\n- If you want to use the command-line examples in this guide, install the [\\`gcloud\\` command-line tool](/sdk).\n- If you want to use the API examples in this guide, set up [API access](/deployment-manager/docs/reference/latest).\n- Understand how to [create a basic configuration](/deployment-manager/docs/configuration/create-basic-configuration).\n\nPreviewing a new configuration\n------------------------------\n\nPreview a configuration by using the Google Cloud CLI or by making a\ndirect request to the API. \n\n### gcloud\n\nIf you're using the Google Cloud CLI, use the `create` sub-command\nwith the `--preview` flag: \n\n gcloud deployment-manager deployments create example-config --config configuration-file.yaml \\\n --preview\n\nThe server returns a list of resources whose state is `IN_PREVIEW` for you\nto review: \n\n The fingerprint of the deployment is ulPDrJON8E5ySHKC5fcukw==\n Waiting for create [operation-1492785372594-54dae2ddbff50-58d45d53-12d483cf]...done.\n Create operation operation-1492785372594-54dae2ddbff50-58d45d53-12d483cf completed successfully.\n NAME TYPE STATE ERRORS INTENT\n datadisk-example compute.v1.disk IN_PREVIEW [] CREATE_OR_ACQUIRE\n vm-example compute.v1.instance IN_PREVIEW [] CREATE_OR_ACQUIRE\n\n### API\n\nIn the API, use the [`insert()`](/deployment-manager/docs/reference/latest/deployments/insert)\nmethod with a request body that contains the `target` and `name` fields and\nthe `preview=true` query parameter. Provide your configuration in the\n`target` field.\n\nFor example, the following API request previews a simple template: \n\n POST https://www.googleapis.com/deploymentmanager/v2/projects/myproject/global/deployments?preview=true\n\n {\n \"name\": \"example-config\",\n \"target\": {\n \"config\": {\n \"content\": \"resources:\\n- name: vm-created-by-cloud-config\\n type: compute.v1.instance\\n properties:\\n zone: us-central1-a\\n machineType: https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1\\n disks:\\n - deviceName: boot\\n type: PERSISTENT\\n boot: true\\n autoDelete: true\\n initializeParams:\\n diskName: disk-created-by-cloud-config\\n sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140619\\n networkInterfaces:\\n networkInterfaces:\\n - network: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default\"\n }\n }\n }\n\nWhen a deployment is in preview mode, you can move forward with the deployment in\none of three ways:\n\n- Deploy the configuration by [performing an update](/deployment-manager/docs/deployments/updating-deployments#make_the_update_request).\n- [Cancel the preview](#cancelpreview) and then delete the deployment.\n- [Update the preview](#performing_multiple_previews).\n\nPerforming multiple previews\n----------------------------\n\nIf you want to change your configuration and perform another preview,\nuse the `update` command with the `--preview` flag: \n\n gcloud deployment-manager deployments update example-config \\\n --config new-config.yaml --preview\n\nIn the API, make a\n[`PUT()`](/deployment-manager/docs/reference/latest/deployments/update)\nrequest with an existing deployment and provide the `preview=true` query\nparameter. The request body must contain the `intent`, `target`, and `name`\nfields. For example, the following API request previews a simple update: \n\n PUT https://www.googleapis.com/deploymentmanager/v2/projects/myproject/global/deployments/example-config?preview=true\n\n {\n \"target\": {\n \"config\": {\n \"content\": \"resources:\\n- name: vm-created-by-cloud-config\\n type: compute.v1.instance\\n properties:\\n zone: us-central1-a\\n machineType: https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1\\n disks:\\n - deviceName: boot\\n type: PERSISTENT\\n boot: true\\n autoDelete: true\\n initializeParams:\\n diskName: disk-created-by-cloud-config\\n sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-7-wheezy-v20140619\\n networkInterfaces:\\n - network: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default\"\n }\n },\n \"name\": \"example-config\"\n }\n\n| **Note:** In the API, you need to provide the deployment name in both the URL and in the request body.\n\nDeploying or canceling a preview\n--------------------------------\n\nAfter previewing a deployment, you can move forward with the deployment by\nperforming an update and committing the configuration. For example, assume you\nhave a deployment named example-config currently in preview mode. You can move\nforward with the deployment by running the following command: \n\n gcloud deployment-manager deployments update example-config\n\nDeployment Manager uses the last previewed configuration to create a\ndeployment.\n\nAlternatively, if you don't want to move forward with the configuration, you can\ncancel the preview, and then delete the deployment: \n\n gcloud deployment-manager deployments cancel-preview example-config\n\n| **Note:** If you perform many previews without canceling or moving forward with any of them, you will end up with many empty deployments. Make sure to [cancel](/deployment-manager/docs/deployments/updating-deployments#cancelpreview) and delete the deployments that you previewed but no longer need once you are done with them.\n\nWhile a deployment is in preview mode, you cannot move forward with another\nconfiguration. For example, assume you have a deployment called\n`example-config` that is in preview mode using a configuration named\n`vm.yaml`. You decide that you want to deploy a new configuration named\n`two_vms.yaml` to the same deployment, skipping the preview process. While\n`example-config` is still in preview mode, you cannot deploy a new\nconfiguration. Cancel the preview, and then\n[update the deployment](/deployment-manager/docs/deployments/updating-deployments)\nwith the new configuration.\n\nWhat's next\n-----------\n\n- Learn more about [configuration files](/deployment-manager/docs/configuration).\n- [Make an update](/deployment-manager/docs/deployments/updating-deployments) to your deployment after you deploy it."]]