Cloud Deployment Manager akan mencapai akhir dukungan pada 31 Desember 2025. Jika saat ini Anda menggunakan Deployment Manager, migrasikan ke Infrastructure Manager atau teknologi deployment alternatif paling lambat 31 Desember 2025 untuk memastikan layanan Anda berlanjut tanpa gangguan.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara membuat deployment. Deployment adalah
instansiasi serangkaian resource yang ditentukan dalam
konfigurasi. Anda memberikan konfigurasi yang valid
dalam permintaan untuk membuat deployment. Deployment dapat berisi sejumlah resource di berbagai layanan Google Cloud . Saat
Anda membuat deployment, Deployment Manager akan membuat semua
resource yang dijelaskan di masing-masing Google Cloud API.
Sebelum memulai
Jika Anda ingin menggunakan contoh command line dalam panduan ini, instal alat command line`gcloud`.
Jika Anda ingin menggunakan contoh API dalam panduan ini, siapkan akses API.
Saat membuat deployment, Anda membuat
resource Deployment
yang berisi kumpulan resource. Setiap resource ditentukan secara eksplisit
dalam konfigurasi yang Anda berikan dalam permintaan Anda.
gcloud
Dengan Google Cloud CLI, gunakan perintah deployments create:
Flag --config adalah jalur relatif ke file konfigurasi YAML Anda.
Secara default, jika konfigurasi Anda menyertakan resource yang sudah ada
di project Anda, resource tersebut akan diperoleh oleh deployment, dan dapat
dikelola menggunakan deployment. Jika Anda tidak ingin mendapatkan resource,
Anda harus menggunakan opsi --create-policy, seperti pada perintah gcloud beta
berikut:
Jika Anda mengimpor template, Anda juga harus memberikan
template tersebut sebagai bagian dari isi permintaan. Misalnya, permintaan API berikut
memiliki target yang mengimpor satu template, bernama vm_template.jinja:
Saat Anda membuat deployment baru, jika resource yang ingin Anda buat sudah ada di project Anda, resource tersebut akan diperoleh oleh deployment.
Dalam kasus tersebut, Deployment Manager tidak membuat resource baru.
Jika Anda tidak ingin mendapatkan resource yang ada, Anda
harus menggunakan kebijakan CREATE untuk deployment Anda.
Anda dapat menggunakan kebijakan berikut untuk membuat resource:
CREATE_OR_ACQUIRE - [Default] Deployment Manager mendapatkan
resource yang ada di project, atau membuat resource jika tidak ada. Untuk mendapatkan resource, Deployment Manager akan memeriksa konfigurasi Anda untuk mengetahui properti resource yang sedang Anda coba buat. Jika ada resource yang sudah ada dengan properti yang sama, Deployment Manager akan mendapatkan resource tersebut sebagai bagian dari deployment Anda.
Properti yang diperiksa Deployment Manager bergantung pada jenis
resource yang Anda buat, dan mungkin mencakup:
name resource
type resource
zone atau region resource, jika ada
Properti ini adalah bagian dari URL untuk permintaan API GET untuk resource.
Untuk melihat properti yang digunakan Deployment Manager untuk mendapatkan resource,
lihat dokumentasi API untuk metode GET resource. Misalnya, untuk instance Compute Engine, URL permintaan untuk metode instances.get mencakup resourceId (name dalam konfigurasi Anda), zone, dan project.
CREATE - Deployment Manager membuat resource yang tidak ada. Jika ada resource dalam konfigurasi Anda yang sudah ada di project, deployment akan gagal.
ACQUIRE - Deployment Manager mendapatkan resource yang sudah ada, menggunakan kriteria yang sama seperti CREATE_OR_ACQUIRE.
Gunakan kebijakan ACQUIRE jika Anda memiliki sejumlah resource yang sudah ada di project, dan ingin mengelolanya bersama-sama, sebagai satu deployment.
Dalam template atau konfigurasi, Anda harus memberikan properti
yang diperlukan untuk resource ini seolah-olah Anda sedang membuatnya. Jika ada resource dalam konfigurasi Anda yang tidak ada di project, deployment akan gagal.
Mencantumkan deployment Anda
Lihat daftar deployment Anda di Google Cloud console, API,
atau Google Cloud CLI.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-19 UTC."],[[["\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)."]]