Cloud Deployment Manager ne sera plus pris en charge à partir du 31 décembre 2025. Si vous utilisez actuellement Deployment Manager, veuillez migrer vers Infrastructure Manager ou vers une autre technologie de déploiement d'ici le 31 décembre 2025 pour que vos services continuent de fonctionner sans interruption.
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page explique comment configurer votre projet pour que Deployment Manager puisse créer des instances de machines virtuelles Compute Engine à l'aide d'images de système d'exploitation appartenant à un autre projet.
Supposons par exemple que vous avez un projet nommé "Projet incroyable", dans lequel Deployment Manager crée et gère des instances de machines virtuelles. Supposons maintenant que vous devez utiliser des images privées appartenant à un projet différent nommé "Images de bases de données".
Pour vous permettre d'accéder à ces images, le propriétaire du projet "Images de bases de données" doit accorder le rôle IAM roles/compute.imageUser au compte de service des API Google de "Projet incroyable". Votre projet pourra ensuite utiliser les images du projet "Images de bases de données".
Vous pouvez également utiliser ce processus pour accorder l'accès aux images d'autres projets aux groupes d'instances gérés.
En accordant le rôle compute.imageUser, vous accordez des autorisations pour toutes les images du projet concerné. Il n'est pas possible de partager des images spécifiques.
Le propriétaire du projet contenant les images doit autoriser le compte de service des API Google du projet qui a besoin de les utiliser à accéder aux images.
Accédez à la page IAM de la console Google Cloud du projet qui doit accéder aux images privées appartenant à un autre projet.
Si vous y êtes invité, sélectionnez votre projet dans la liste. N'oubliez pas que vous devez sélectionner le projet qui doit accéder aux images stockées dans un autre projet.
Recherchez le compte de service des API Google, dont l'adresse e-mail est au format suivant :
Notez l'adresse e-mail ci-dessus. Ensuite, un propriétaire du projet contenant les images souhaitées peut accorder le rôle roles/compute.imageUser au compte de service des API Google.
Console
Toujours dans la console Google Cloud , accédez à la page IAM du projet contenant les images auxquelles vous souhaitez accéder.
Le corps de la requête doit contenir la liste des liaisons que vous souhaitez appliquer à ce projet. Le rôle roles/compute.imageUser doit faire partie de la liaison. Exemple :
Utiliser des images provenant d'autres projets dans votre configuration
Une fois qu'un projet a été autorisé à accéder aux images d'un autre projet, les utilisateurs du projet peuvent se servir des images en spécifiant l'ID du projet auquel les images appartiennent dans vos modèles ou configurations :
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/03 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/03 (UTC)."],[[["\u003cp\u003eDeployment Manager can create Compute Engine VM instances using OS images from a different project by granting the \u003ccode\u003eroles/compute.imageUser\u003c/code\u003e IAM role to the Google APIs service account of the project requiring access.\u003c/p\u003e\n"],["\u003cp\u003eTo allow one project to utilize images from another, the image-owning project's owner must grant the \u003ccode\u003eroles/compute.imageUser\u003c/code\u003e role to the requesting project's Google APIs service account.\u003c/p\u003e\n"],["\u003cp\u003eAccess to images from another project is granted at the project level, meaning all images within that project become accessible, and this access is specific to service accounts, not general user groups.\u003c/p\u003e\n"],["\u003cp\u003eOnce access is granted, users can utilize images from the external project in their configurations by specifying the project ID in the image URI, for example: \u003ccode\u003eprojects/[PROJECT_ID]/global/images/[IMAGE_NAME]\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egcloud\u003c/code\u003e command-line tool and the API can be used to add a binding to the IAM policy for the project.\u003c/p\u003e\n"]]],[],null,["# Using Images from Other Projects\n\nThis page describes how to configure your project so that Deployment Manager can\ncreate Compute Engine virtual machine instances using\n[operating system images](/compute/docs/images) that belong to another project.\n\nFor example, assume you have a project named Awesome Project where\nDeployment Manager creates and manages VM instances. Now, let's assume you need\nto use private images that belong to a different project named Database Images.\nTo grant access to these images, the owner of Database Images must grant\nthe IAM role `roles/compute.imageUser` to the\n[Google APIs service account](/deployment-manager/docs/access-control#access_control_for_deployment_manager)\nof Awesome Project, and Awesome Project can then use images from the Database\nImages project.\n\nYou can also use this process to grant\n[managed instance groups](/compute/docs/instance-groups#managed_instance_groups)\naccess to images from other projects.\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- Read about Deployment Manager [configurations](/deployment-manager/docs/configuration/create-basic-configuration).\n- Read about Compute Engine [private images](/compute/docs/images).\n- Read about [Identity and Access Management (IAM)](/iam) documentation.\n- Read about [Deployment Manager IAM roles](/compute/docs/access/iam#iam_roles), in particular, the `roles/compute.imageUser` role.\n\nLimitations\n-----------\n\nThe following are restrictions for using this feature:\n\n- You must grant the `compute.imageUser` role on the project level to your project's [Google APIs service account](/deployment-manager/docs/access-control#access_control_for_deployment_manager).\n- Granting the `compute.imageUser` role grants permissions to all images in the specific project. It is not possible to share specific images.\n- You must grant this role to specific users, and not to [`allAuthenticatedUsers`](/iam/docs/principals-overview#allauthenticatedusers) or [`allUsers`](/iam/docs/principals-overview#allusers).\n\nGranting access to images\n-------------------------\n\nTo grant access to images that belong to another project, the owner of the\nproject that owns the images must grant access to the Google APIs service\naccount of the project that wants to use the images.\n\n1. Go to the IAM page in the Google Cloud console of the project that needs access to private images owned by another project. [Go to the IAM page](https://console.cloud.google.com/iam-admin/iam/)\n\n2. If prompted, select your project from the list. Remember to select the project that needs access to images stored in another project.\n3. Look for **Google APIs service account**, which has an email address in the\n following format:\n\n [PROJECT_NUMBER]@cloudservices.gserviceaccount.com\n\n | **Note:** This email address requires the project number, which is different than the project ID. To learn how to identify the project number, see [Identifying projects](/compute/docs/projects#projectids).\n4. Make note of the email address above. Next, a project owner of the project\n where the desired images live can grant the Google APIs service account\n the `roles/compute.imageUser` role.\n\n\n ### Console\n\n 1. While still in the Google Cloud console, go to the IAM page of the project that contains the images you want access to. [Go to the IAM page](https://console.cloud.google.com/iam-admin/iam/)\n\n 2. Select the project from the project list.\n 3. Click the **Add** button to add a new member.\n 4. In the **Members** box, enter the email address of the service account.\n 5. Expand the **Roles** dropdown and select **Compute Engine \\\u003e Compute Image User**.\n 6. Click **Add** to add the account.\n\n ### gcloud\n\n With the Google Cloud CLI, add a binding to the IAM policy for the project: \n\n ```\n gcloud projects add-iam-policy-binding [PROJECT_ID] \\\n --member serviceAccount:[SERVICE_ACCOUNT_EMAIL] --role roles/compute.imageUser\n ```\n\n where:\n - `[PROJECT_ID]` is the ID of the project containing images you want to share.\n - `[SERVICE_ACCOUNT_EMAIL]` is the email of the service account.\n\n For example: \n\n ```\n gcloud projects add-iam-policy-binding database-images \\\n --member serviceAccount:123456789012@cloudservices.gserviceaccount.com \\\n --role roles/compute.imageUser\n ```\n\n ### API\n\n In the API, make a `POST` request to the following URL, where\n `[PROJECT_ID]` is the ID of the project containing the images you want to\n share. \n\n POST https://cloudresourcemanager.googleapis.com/v1/projects/$[PROJECT_ID]:setIamPolicy\n\n The request body should contain the list of bindings you want to apply\n to this project. The `roles/compute.imageUser` role should be part\n of the binding. For example: \n\n {\n \"policy\": {\n \"version\": \"0\",\n \"bindings\": [\n {\n \"role\": \"roles/owner\",\n \"members\": [\n \"user:example@gmail.com\"\n ]\n },\n {\n \"role\": \"roles/compute.imageUser\",\n \"members\": [\n \"serviceAccount:123456789012@cloudservices.gserviceaccount.com\"\n ]\n }\n ]\n }\n\n }\n\n \u003cbr /\u003e\n\nUsing images from other projects in your configuration\n------------------------------------------------------\n\nAfter a project has been granted access to images from another project, users of\nthe project can use the images by specifying the project ID of the project that\nthe images belong to in your templates or configurations: \n\n image: projects/[PROJECT_ID]/global/images/[IMAGE_NAME]\n\nFor example, if the image project ID is `database-images`, then you might\nprovide the following image URI in your configuration: \n\n```\nresources:\n- name: a-special-vm\n type: compute.v1.instances\n properties:\n machineType: zones/us-central1-a/machineTypes/f1-micro\n image: projects/database-images/global/images/example-database-image\n ...\n```\n\nAfter you have added the image, [finish creating your configuration](/deployment-manager/docs/configuration/create-basic-configuration), then [deploy it](/deployment-manager/docs/deployments).\n\nWhat's next?\n------------\n\n- Learn more about [sharing images](/compute/docs/images/sharing-images-across-projects).\n- Learn more about Compute Engine [images](/compute/docs/images).\n- Read about other [IAM roles](/iam/docs/understanding-roles) you can grant.\n- Learn more about [service accounts](/compute/docs/access/service-accounts)."]]