Il supporto di Cloud Deployment Manager terminerร il 31 dicembre 2025. Se al momento utilizzi Deployment Manager, esegui la migrazione a Infrastructure Manager o a una tecnologia di deployment alternativa entro il 31 dicembre 2025 per assicurarti che i tuoi servizi continuino senza interruzioni.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questa pagina descrive come creare un deployment. Un deployment รจ un'istanza di un insieme di risorse definite in una configurazione. Fornisci una configurazione valida nella richiesta di creazione del deployment. Un deployment puรฒ contenere
un numero di risorse, in una varietร di servizi. Google Cloud Quando
crei un deployment, Deployment Manager crea tutte le
risorse descritte nelle rispettive Google Cloud API.
Quando crei un deployment, crei una
risorsa di deployment
che contiene una raccolta di risorse. Ogni risorsa รจ definita in modo esplicito
in una configurazione che fornisci nella richiesta.
gcloud
Con Google Cloud CLI, utilizza il comando deployments create:
Il flag --config รจ un percorso relativo al file di configurazione YAML.
Per impostazione predefinita, se la configurazione include risorse giร presenti nel progetto, queste vengono acquisite dal deployment e possono essere gestite utilizzando il deployment. Se non vuoi acquisire una risorsa,
devi utilizzare l'opzione --create-policy, come nel seguente comando gcloud beta:
Se importi template, devi fornirli anche come parte del corpo della richiesta. Ad esempio, la seguente richiesta API
ha un target che importa un modello denominato vm_template.jinja:
Impostazione del criterio per la creazione di risorse
Quando crei un nuovo deployment, se una risorsa che vuoi creare esiste giร nel tuo progetto, viene acquisita dal deployment.
In questi casi, Deployment Manager non crea una nuova risorsa.
Se non vuoi acquisire una risorsa esistente, devi utilizzare il criterio CREATE per il deployment.
Puoi utilizzare i seguenti criteri per creare le tue risorse:
CREATE_OR_ACQUIRE - [Predefinito] Deployment Manager acquisisce le risorse esistenti nel progetto o le crea se non esistono. Per acquisire una risorsa, Deployment Manager controlla la configurazione
per le proprietร della risorsa che stai tentando di creare. Se esiste una risorsa con le stesse proprietร , Deployment Manager la acquisisce nell'ambito del deployment.
Le proprietร che Deployment Manager controlla dipendono dal tipo di
risorsa che stai creando e potrebbero includere:
Il name della risorsa
Il type della risorsa
Il zone o il region della risorsa, se applicabile
Le proprietร fanno parte dell'URL della richiesta API GET per la risorsa.
Per vedere quali proprietร utilizza Deployment Manager per acquisire una risorsa,
consulta la documentazione dell'API per il metodo GET della risorsa. Ad esempio,
per le istanze Compute Engine, l'URL della richiesta per
il metodo instances.get
include resourceId (name nella configurazione), zone e
project.
CREATE - Deployment Manager crea risorse che non esistono. Se una delle risorse nella configurazione esiste giร nel progetto, il deployment non va a buon fine.
ACQUIRE - Deployment Manager acquisisce le risorse giร esistenti,
utilizzando gli stessi criteri di CREATE_OR_ACQUIRE.
Utilizza il criterio ACQUIRE se hai giร diverse risorse nel tuo progetto e vuoi gestirle insieme, come un unico deployment.
Nel modello o nella configurazione, devi fornire le proprietร richieste per queste risorse come se le stessi creando. Se una delle risorse nella configurazione non esiste nel progetto, il deployment non va a buon fine.
Elenco dei deployment
Visualizza un elenco delle tue implementazioni nella Google Cloud console, nell'API o in Google Cloud CLI.
Console
Vai alla pagina Deployment
nella console Google Cloud .
gcloud
Con Google Cloud CLI, utilizza il sottocomando deployments list:
gcloud deployment-manager deployments list
API
Nell'API, invia una richiesta GET vuota alla raccolta Deployments:
GET https://www.googleapis.com/deploymentmanager/v2beta1/projects/myproject/global/deployments
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema รจ stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-03 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)."]]