[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-03 (世界標準時間)。"],[[["\u003cp\u003eThis page outlines how to share project-specific types and type providers with other projects by granting the \u003ccode\u003edeploymentmanager.typeViewer\u003c/code\u003e (beta) role.\u003c/p\u003e\n"],["\u003cp\u003eSharing types requires a project owner to grant the \u003ccode\u003edeploymentmanager.typeViewer\u003c/code\u003e role to the consuming project's Google APIs service account, allowing the project to deploy those types.\u003c/p\u003e\n"],["\u003cp\u003eTo enable individual users to list and view shared types, the project owner must also grant each user the \u003ccode\u003edeploymentmanager.typeViewer\u003c/code\u003e role.\u003c/p\u003e\n"],["\u003cp\u003eThe shared types can then be specified in configurations using the syntax \u003ccode\u003e[PROJECT_ID]/composite:[TYPE]\u003c/code\u003e for composite types or \u003ccode\u003e[PROJECT_ID]/[TYPE]:[COLLECTION]\u003c/code\u003e for type providers, where \u003ccode\u003e[PROJECT_ID]\u003c/code\u003e is the project owning the type.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edeploymentmanager.typeViewer\u003c/code\u003e role is a beta offering which is subject to the Pre-GA Offerings Terms and has certain limitations, such as not being able to limit sharing to individual types or to use it with \u003ccode\u003eallAuthenticatedUsers\u003c/code\u003e or \u003ccode\u003eallUsers\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Sharing Types Across Projects\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\nThis page describes how to share\n[types and type providers](/deployment-manager/docs/fundamentals#types) that\nbelong to your project with other projects. For example, assume you have a\nproject that is responsible for maintaining pre-approved type providers for your\ncompany. You want to be able to share these type providers from that project\nwith other projects and to use the project as a central repository of types.\nSimilarly, you can also use this method to share composite types across\nprojects.\n\nTo set up access, a project owner from the project that owns the type\nwill need to grant the `deploymentmanager.typeViewer` (beta) role to the service\naccount of the project that wants to consume the types. They also need to\ngrant the role to users who want to view and list types from another project..\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 [Types](/deployment-manager/docs/fundamentals#types).\n- Read the [Identity and Access Management (IAM)](/iam) documentation.\n\nLimitations\n-----------\n\nThe following are restrictions for using this feature:\n\n- Granting the `deploymentmanager.typeViewer` role grants permissions to all types in the specific project. It is not possible to limit sharing to individual types.\n- It is not possible to grant this role to [`allAuthenticatedUsers`](/iam/docs/principals-overview#allauthenticatedusers) or [`allUsers`](/iam/docs/principals-overview#allusers).\n\nGranting a project access to use types\n--------------------------------------\n\nTo grant access to types that belong to other projects, the owner of the\nproject that owns the types in question must grant the `deploymentmanager.typeViewer`\nrole to the\n[Google APIs service account](/deployment-manager/docs/access-control#access_control_for_deployment_manager)\nof the project that wants to consume the types.\n\n1. Go to the IAM page in the Google Cloud console of the project that will be consuming the types. [Go to the IAM page](https://console.cloud.google.com/iam-admin/iam/)\n\n2. If prompted, select your project from the list.\n3. Look for the **Google APIs service account**, which has the email\n address in the following format:\n\n [PROJECT_NUMBER]@cloudservices.gserviceaccount.com\n\n | **Note:** This email address requires the project number, not 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 types live can grant the Google APIs service account\n the `roles/deploymentmanager.typeViewer` 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 types you want to share. [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 **Other \\\u003e Deployment Manager Types Viewer (beta)**.\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/deploymentmanager.typeViewer\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 in the project you want to share types with.\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/deploymentmanager.typeViewer\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 types 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/deploymentmanager.typeViewer` 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/deploymentmanager.typeViewer\",\n \"members\": [\n \"serviceAccount:123456789012@cloudservices.gserviceaccount.com\"\n ]\n }\n ]\n }\n\n }\n\n \u003cbr /\u003e\n\nUsing types from other projects in your configuration\n-----------------------------------------------------\n\nOnce you have access to your types, you can specify the type in\nconfigurations using the syntax. For\n[composite types](/deployment-manager/docs/configuration/composite-types/creating-composite-types): \n\n type: [PROJECT_ID]/composite:[TYPE]\n\nFor [type providers](/deployment-manager/docs/configuration/type-providers/process-adding-api): \n\n type: [PROJECT_ID]/[TYPE]:[COLLECTION]\n\nWhere:\n\n- `[PROJECT_ID]` is the project ID that owns the type.\n- `[TYPE]` is the name of the type provider or the composite type.\n- `[COLLECTION]` is the specific resource you are creating. This is only applicable for base types. For more information on specifying base types, read [Calling a Type Provider in a Configuration](/deployment-manager/docs/configuration/type-providers/calling-type-provider).\n\nFor example, if the project ID is `my-type-repository`, then you might\nprovide the following type specification: \n\n```\nresources:\n- name: a-special-vm\n type: my-type-repository/composite:autoscaled-igm\n properties:\n ...\n```\n\nGranting users the ability to list and view types\n-------------------------------------------------\n\nGranting the project's service account the `deploymentmanager.typeViewer` role\nallows the project to deploy these types in your configurations but does not\nallow users to view or list these types. If you want to grant individual users\nto ability to view types, you must grant the `deploymentmanager.typeViewer`\nrole to each user.\n\nFor example, in order for Jane to run the\n`gcloud beta deployment-manager types list --project another-project`\ncommand for a project that doesn't belong to her, the owner of `another-project`\nmust grant Jane the `deploymentmanager.typeViewer` role.\n\nUsing the gcloud CLI, you can grant Jane the role like so: \n\n gcloud projects add-iam-policy-binding another-project \\\n --member user:jane@gmail.com --role deploymentmanager.typeViewer\n\nFor comprehensive instructions on adding and removing roles from users,\nread the documentation for\n[granting, changing, and revoking access to project members](/iam/docs/granting-changing-revoking-access).\n\nWhat's next?\n------------\n\n- Read about other [IAM roles](/iam/docs/understanding-roles) you can grant.\n- Learn more about [service accounts](/compute/docs/access/service-accounts)."]]