Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Por padrão, os usuários de um projeto criam discos permanentes ou copiam
imagens usando qualquer uma das
imagens públicas
e qualquer imagem que
os membros possam acessar por meio dos papéis do IAM.
No entanto, em algumas situações convém restringir os membros do projeto para que eles
só possam criar discos de inicialização de imagens que contenham software aprovado que atenda
à sua política ou aos requisitos de segurança.
Use o recurso Imagem confiável para definir uma política da organização que
permita que os membros criem discos permanentes apenas de imagens em projetos
específicos.
Configure a autenticação, caso ainda não tenha feito isso.
A autenticação é
o processo de verificação da sua identidade para acesso a serviços e APIs do Google Cloud .
Para executar códigos ou amostras de um ambiente de desenvolvimento local, autentique-se no
Compute Engine selecionando uma das seguintes opções:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and
APIs, you don't need to set up authentication.
gcloud
Instale a CLI do Google Cloud.
Após a instalação,
inicialize a Google Cloud CLI executando o seguinte comando:
As políticas de imagem confiável não impedem os usuários de criar recursos de imagem nos projetos locais.
Defina restrições de acesso a imagens
Execute uma política de acesso a imagens definindo uma restrição
compute.trustedImageProjects no seu projeto, na sua pasta ou na sua organização. Você precisa ter permissão para modificar as políticas da organização para definir essas restrições. Por
exemplo,
roles/orgpolicy.policyAdmin
tem permissão para definir essas restrições. Para mais informações sobre como gerenciar políticas no nível do projeto, da pasta ou da organização, consulte
Como usar restrições.
É possível definir restrições em todas as imagens públicas disponíveis no Compute Engine.
Para uma lista de nomes de projetos de imagem, consulte Detalhes dos sistemas operacionais.
Também é possível restringir as imagens de aprendizado de máquina (ML) disponíveis no
Compute Engine usando o projeto ml-images. Se você estiver usando o
acesso VPC sem servidor,
conceda ao seu projeto permissão para usar as imagens da VM do Compute Engine do
projeto serverless-vpc-access-images.
Use o Google Cloud console ou a Google Cloud CLI para definir restrições de acesso a imagens.
Console
Por exemplo, para definir uma restrição para envolvidos no projeto, faça o seguinte:
Na lista Valores da política, selecione se esta política da organização precisa permitir ou negar acesso a todos os projetos de imagem ou especifique um conjunto personalizado de projetos para permitir ou negar acesso.
Para definir a regra da política, conclua uma das seguintes opções:
Para permitir que os usuários criem discos de inicialização com todas as imagens públicas, selecione Permitir tudo.
Para impedir que os usuários criem discos de inicialização com todas as imagens públicas, selecione Negar tudo.
Para especificar um conjunto selecionado de imagens públicas que os usuários podem usar para criar discos de inicialização, selecione Personalizado.
Um campo Tipo de política e Valores personalizados é exibido.
Na lista Tipo de política, selecione Permitir ou Negar.
No campo Valores personalizados, insira o nome do projeto de imagem usando o formato projects/IMAGE_PROJECT.
Substitua IMAGE_PROJECT pelo projeto de imagem
em que você quer definir a restrição.
É possível adicionar vários projetos de imagem. Para cada projeto de imagem que você quer adicionar, clique em Adicionar e insira o nome do projeto.
Para salvar a regra, clique em Concluído.
Para salvar e aplicar a política da organização, clique em Salvar.
Abra o arquivo policy.yaml em um editor de texto e modifique a restrição compute.trustedImageProjects. Adicione as restrições necessárias e remova as que não são mais necessárias. Quando terminar de editar o arquivo, salve as alterações. Por exemplo, defina a entrada de restrição a seguir no arquivo de política:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-18 UTC."],[[["\u003cp\u003eTrusted image policies allow you to restrict the creation of persistent disks to only use images from specific projects, helping to enforce security and policy requirements.\u003c/p\u003e\n"],["\u003cp\u003eYou can set image access constraints by using the \u003ccode\u003ecompute.trustedImageProjects\u003c/code\u003e constraint at the project, folder, or organization level, allowing you to control which images can be used for boot disks.\u003c/p\u003e\n"],["\u003cp\u003eTrusted image policies do not affect access to custom images within your local project or image files in Cloud Storage buckets, and they do not prevent users from creating image resources in their local projects.\u003c/p\u003e\n"],["\u003cp\u003eImage access constraints can be configured to allow or deny the use of all public images or to specify a custom set of image projects that users can create boot disks from.\u003c/p\u003e\n"],["\u003cp\u003eTo implement constraints, you can use either the Google Cloud console or the gcloud CLI, with the latter requiring you to modify a policy.yaml file that outlines your specific restrictions.\u003c/p\u003e\n"]]],[],null,["# Setting up trusted image policies\n\n*** ** * ** ***\n\nBy default, users in your project can create persistent disks or copy\nimages using any of the\n[public images](/compute/docs/images#os-compute-support)\nand any images that\n[principals can access through IAM roles](/compute/docs/images/sharing-images-across-projects).\nHowever, in some situations you might want to restrict principals so that they\ncan create boot disks only from images that contain approved software that meets\nyour policy or security requirements.\n\nUse the Trusted image feature to define an organization policy that\nallows principals to create persistent disks only from images in specific\nprojects.\n\nTo restrict the locations where your images can be used, read\n[restricting use of your shared images, disks, and snapshots](/compute/docs/images/sharing-images-across-projects#restrict).\n\nBefore you begin\n----------------\n\n- Read the [Using constraints](/resource-manager/docs/organization-policy/using-constraints) page to learn about managing policies at organization level.\n- Read the [Understanding hierarchy evaluation](/resource-manager/docs/organization-policy/understanding-hierarchy) page to learn how organization policies propagate.\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:\n\n Select the tab for how you plan to use the samples on this page: \n\n ### Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n ### gcloud\n\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\n ### REST\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\nLimitations\n-----------\n\n- Trusted image policies do not restrict access to the following images:\n\n - [Custom images](/compute/docs/images#custom_images) in your local project.\n\n - Image files in Cloud Storage buckets.\n\n- Trusted image policies do not prevent users from creating image resources in\n their local projects.\n\nSet image access constraints\n----------------------------\n\nEnact an image access policy by setting a `compute.trustedImageProjects`\nconstraint on your project, your folder, or your organization. You must have\npermission to modify organization policies to set these constraints. For\nexample,\n[`roles/orgpolicy.policyAdmin`](/resource-manager/docs/access-control-org)\nhas permission to set these constraints. For more information about managing\npolicies at the project, folder, or organization level, see\n[Using constraints](/resource-manager/docs/organization-policy/using-constraints).\n\nYou can set constraints on all public images available on Compute Engine.\nFor a list of image project names, see [Operating systems details](/compute/docs/images/os-details).\nYou can also restrict the Machine Learning (ML) images that are available on\nCompute Engine by using the `ml-images` project. If you are using\n[Serverless VPC Access](/vpc/docs/configure-serverless-vpc-access#errors),\ngrant your project permission to use Compute Engine VM images from the\n`serverless-vpc-access-images` project.\n\nUse the Google Cloud console or Google Cloud CLI to set constraints on image access. \n\n### Console\n\nFor example, to set a constraint at the project level, do the following:\n\n1. Go to the **Organization policies** page.\n\n [Go to Organization policies](https://console.cloud.google.com/iam-admin/orgpolicies/)\n2. From the policies list, click **Define trusted image projects** .\n The **Policy details** page displays.\n\n3. On the **Policy details** page, click **Manage Policy** . The **Edit policy**\n page displays.\n\n4. On the **Edit policy** page, select **Customize**.\n\n5. For **Policy enforcement** , select an enforcement option. For information\n about inheritance and the resource hierarchy, see\n [Understanding Hierarchy Evaluation](/resource-manager/docs/organization-policy/understanding-hierarchy).\n\n6. Click **Add rule**.\n\n7. In the **Policy values** list, you can select whether this organization\n policy should allow access to all image projects, deny access to all image\n projects, or you can specify a custom set of projects to allow or deny\n access to.\n\n To set the policy rule, complete one of the following options:\n - To allow users to create boot disks from all public images, select **Allow All**.\n - To restrict users from creating boot disk from all public images, select **Deny All**.\n - To specify a select set of public images that users can create boot\n disks from, select **Custom** .\n A **Policy type** and **Custom values** field displays.\n\n 1. In the **Policy type** list, select **Allow** or **Deny**.\n 2. In the **Custom values** field, enter the name of the image project\n using the `projects/`\u003cvar translate=\"no\"\u003eIMAGE_PROJECT\u003c/var\u003e format.\n\n Replace \u003cvar translate=\"no\"\u003eIMAGE_PROJECT\u003c/var\u003e with the image project\n you want to set the constraint on.\n\n You can add multiple image projects. For each image project that\n you want to add, click **Add** and enter the image project name.\n8. To save the rule, click **Done**.\n\n9. To save and apply the organization policy, click **Save**.\n\nFor more information about creating organization policies, see\n[Creating and managing organization policies](/resource-manager/docs/organization-policy/creating-managing-policies).\n\n### gcloud\n\nFor example, to set a constraint at the project level, do the following:\n\n1. Get the existing policy settings for your project by using the [`resource-manager org-policies describe`](/sdk/gcloud/reference/resource-manager/org-policies/describe) command.\n\n ```\n gcloud resource-manager org-policies describe \\\n compute.trustedImageProjects --project=PROJECT_ID \\\n --effective \u003e policy.yaml\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your project ID.\n2. Open the `policy.yaml` file in a text editor and modify the\n `compute.trustedImageProjects` constraint. Add the restrictions that you\n need and remove the restrictions that you no longer require. When you\n have finished editing the file, save your changes. For example,\n you might set the following constraint entry in your policy file:\n\n ```\n constraint: constraints/compute.trustedImageProjects\n listPolicy:\n allowedValues:\n - projects/debian-cloud\n - projects/cos-cloud\n deniedValues:\n - projects/IMAGE_PROJECT\n ```\n\n Replace \u003cvar translate=\"no\"\u003eIMAGE_PROJECT\u003c/var\u003e with the name of the image project that you want to restrict in your project.\n\n Optionally, you might want to deny access to all images outside of\n the custom images in your project. For that situation, use the\n following example: \n\n ```\n constraint: constraints/compute.trustedImageProjects\n listPolicy:\n allValues: DENY\n ```\n\n \u003cbr /\u003e\n\n3. Apply the `policy.yaml` file to your project. If your\n [organization or folder has existing constraints](/resource-manager/docs/organization-policy/understanding-policies),\n those constraints might conflict with project-level constraints that\n you set. To apply the constraint, use the [`resource-manager org-policies set-policy`](/sdk/gcloud/reference/resource-manager/org-policies/set-policy) command.\n\n ```\n gcloud resource-manager org-policies set-policy \\\n policy.yaml --project=PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your project ID.\n\nWhen you have finished configuring the constraints,\ntest those constraints to ensure that they create the restrictions that you\nneed.\n\nWhat's next\n-----------\n\n- Learn more about the [Organization Policy Service](/resource-manager/docs/organization-policy/overview).\n- See what [public images](/compute/docs/images) are available for you to use by default.\n- [Share your private image](/compute/docs/images/sharing-images-across-projects) with other projects.\n- Learn how to [restrict use of your shared images, disks, and snapshots](/compute/docs/images/sharing-images-across-projects#restrict).\n- Learn how to [start an instance from an image](/compute/docs/instances/creating-and-starting-an-instance#startinginstancwithimage)."]]