这些属性是资源 GET API 请求的网址的一部分。要查看 Deployment Manager 用于获取资源的属性,请参阅资源的 GET 方法的 API 文档。例如,对于 Compute Engine 实例,instances.get 方法的请求网址包括 resourceId(配置中的 name)、zone 和 project。
[[["易于理解","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\u003eA deployment is the instantiation of resources defined in a configuration, creating them across various Google Cloud services as outlined.\u003c/p\u003e\n"],["\u003cp\u003eDeployments are created using either the \u003ccode\u003egcloud\u003c/code\u003e command-line tool with the \u003ccode\u003edeployments create\u003c/code\u003e command or through an API \u003ccode\u003einsert()\u003c/code\u003e request, providing a configuration file or inline configuration.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003e--config\u003c/code\u003e flag in the \u003ccode\u003egcloud\u003c/code\u003e command-line tool specifies the path to the YAML configuration file which contains the parameters of your deployment.\u003c/p\u003e\n"],["\u003cp\u003eWhen creating a deployment, you can use policies like \u003ccode\u003eCREATE_OR_ACQUIRE\u003c/code\u003e (default), \u003ccode\u003eCREATE\u003c/code\u003e, or \u003ccode\u003eACQUIRE\u003c/code\u003e to manage how existing resources in your project are handled.\u003c/p\u003e\n"],["\u003cp\u003eThe list of the current deployments can be viewed from the console, with the gcloud \u003ccode\u003edeployments list\u003c/code\u003e command, or with an API \u003ccode\u003eGET\u003c/code\u003e request.\u003c/p\u003e\n"]]],[],null,["# Creating a Deployment using gcloud or the API\n\nThis page describes how to create a deployment. A deployment is an\ninstantiation of a set of resources that are defined in a\n[configuration](/deployment-manager/docs/configuration). You provide a valid\nconfiguration in the request to create the deployment. A deployment can contain\na number of resources, across a variety of Google Cloud services. When\nyou create a deployment, Deployment Manager creates all of the\ndescribed resources in the respective Google Cloud APIs.\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- Create a [configuration](/deployment-manager/docs/configuration/create-configuration-file).\n\nCreating a deployment\n---------------------\n\nWhen you create a deployment, you are creating a\n[Deployment resource](/deployment-manager/docs/reference/latest/deployments)\nthat contains a collection of resources. Each resource is explicitly defined\nin a configuration that you provide in your request. \n\n### gcloud\n\nWith the Google Cloud CLI, use the `deployments create` command: \n\n gcloud deployment-manager deployments create my-first-deployment \\\n --config vm.yaml\n\nThe `--config` flag is a relative path to your YAML configuration\nfile.\n\nBy default, if your configuration includes resources that are already\nin your project, those resources are acquired by the deployment, and can\nbe managed using the deployment. If you don't want to acquire a resource,\nyou must use the `--create-policy` option, as in the following `gcloud beta`\ncommand: \n\n gcloud beta deployment-manager deployments create my-first-deployment \\\n --config vm.yaml --create-policy CREATE\n\nFor information on what policies you can use when you are creating\ndeployments, see [Setting the policy for creating resources](#create-policy).\n\nIf your deployment is successfully created, you can get a description\nof the deployment: \n\n gcloud deployment-manager deployments describe my-first-deployment\n\n### API\n\nIn the API, make an [`insert()`](/deployment-manager/docs/reference/latest/deployments/insert)\nrequest with the configuration provided inline, in the request body: \n\n POST https://www.googleapis.com/deploymentmanager/v2/projects/myproject/global/deployments\n\n {\n \"name\": \"example-config-with-templates\",\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-v20151104\\n networkInterfaces:\\n - network: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default\\n\"\n }\n }\n }\n\nIf you import [templates](/deployment-manager/docs/configuration/templates/create-basic-template), you must also provide those\ntemplates as part of the request body. For example, the following API request\nhas a `target` that imports one template, named `vm_template.jinja`: \n\n POST https://www-www.googleapis.com/deploymentmanager/v2/projects/myproject/global/deployments\n\n {\n \"name\": \"my-example-config-with-templates-2\",\n \"target\": {\n \"config\": {\n \"content\": \"imports:\\n- path: vm_template.jinja\\n\\nresources:\\n- name: my-vm\\n type: vm_template.jinja\"\n },\n \"imports\": [\n {\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-v20151104\\n networkInterfaces:\\n - network: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default\",\n \"name\": \"vm_template.jinja\"\n }\n ]\n }\n }\n\n| **Note:** When you use the API to create a deployment, the operation might take a substantial length of time to complete. For guidelines on checking the operation's status, read about [managing long-running operations](/deployment-manager/docs/reference/managing-long-running-operations).\n\nSetting the policy for creating resources\n-----------------------------------------\n\n|\n| **Beta**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nWhen you create a new deployment, if a resource that you want to\ncreate already exists in your project, it is acquired by the deployment.\nIn such cases, Deployment Manager does not create a new resource.\nIf you do not want to acquire an existing resource, you\nmust use the `CREATE` policy for your deployment.\n\nYou can use the following policies for creating your resources:\n\n- `CREATE_OR_ACQUIRE` - **\\[Default\\]** Deployment Manager acquires\n resources that exist in the project, or creates resources if they do not\n exist. To acquire a resource, Deployment Manager checks your configuration\n for the properties of the resource you are trying to create. If there is an\n existing resource with the same properties, Deployment Manager acquires\n that resource as part of your deployment.\n\n The properties that Deployment Manager checks depend on the type of\n resource you are creating, and might include:\n - The `name` of the resource\n - The `type` of the resource\n - The `zone` or `region` of the resource, if applicable\n\n The properties are part of the URL for `GET` API request for the resource.\n To see which properties Deployment Manager uses to acquire a resource,\n see the API documentation for the resource's `GET` method. For example,\n for Compute Engine instances, the request URL for\n [`instances.get`](/compute/docs/reference/rest/v1/instances/get) method\n includes the `resourceId` (`name` in your configuration), `zone`, and\n `project`.\n | **Note:** If you want to acquire a resource, you must provide all the required properties of the resource, as if you were creating it.\n- `CREATE` - Deployment Manager creates resources that do not exist. If any\n of the resources in your configuration already exist in the project, the\n deployment fails.\n\n- `ACQUIRE` - Deployment Manager acquires resources that already exist,\n using the same criteria as `CREATE_OR_ACQUIRE`.\n\n Use the `ACQUIRE` policy if you have a number of resources already in your\n project, and want to manage them together, as a single deployment.\n\n In your template or configuration, you must provide the required\n properties for these resources as if you are creating them. If any of\n the resources in your configuration do not exist in the project, the\n deployment fails.\n | **Warning:** Do not acquire resources that are already part of another deployment. If you do, any changes you make to one deployment can cause unexpected behavior with the resources in the other deployment.\n\nListing your deployments\n------------------------\n\nView a list of your deployments in either the [Google Cloud console](https://console.cloud.google.com/), the API,\nor the Google Cloud CLI. \n\n### Console\n\nGo to the [**Deployments**](https://console.cloud.google.com/project/_/deployments) page\nin the Google Cloud console.\n\n### gcloud\n\nWith the Google Cloud CLI, use the `deployments list` subcommand: \n\n gcloud deployment-manager deployments list\n\n### API\n\nIn the API, make an empty `GET` request to the Deployments collection: \n\n GET https://www.googleapis.com/deploymentmanager/v2beta1/projects/myproject/global/deployments\n\nWhat's next\n-----------\n\n- Add [labels to your deployment](/deployment-manager/docs/deployments/add-labels-deployments).\n- [Update your deployment](/deployment-manager/docs/deployments/updating-deployments)."]]