Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Quando fai riferimento a una risorsa Cloud Key Management Service utilizzando l'API Cloud KMS o Google Cloud CLI, utilizza l'ID risorsa. Ad esempio, puoi utilizzare l'ID risorsa di un portachiavi per concedere un ruolo IAM (Identity and Access Management) a quel portachiavi. Questo argomento spiega come ottenere l'ID di un mazzo di chiavi, una chiave e una versione della chiave.
Ottenere l'ID risorsa per un portachiavi
Console
Vai alla pagina Gestione chiavi nella Google Cloud console.
Una chiave contiene zero o più versioni. L'ID risorsa per una versione della chiave è l'ID chiave, più una barra (/), più l'ID versione. Per elencare tutte le versioni di una chiave, fai clic sul nome della chiave. Fai clic sull'icona Altro per la versione e poi su Copia nome risorsa.
gcloud
Elenca tutte le chiavi di un determinato mazzo di chiavi:
gcloud kms keys list --keyring KEY_RING --location LOCATION
La colonna Nome dell'output include l'ID risorsa per ogni chiave. Ad
esempio:
Una chiave ha zero o più versioni. L'ID risorsa di una versione della chiave è costituito dall'ID chiave, da una barra (/) e dall'ID versione. Per elencare tutte le versioni
per una chiave:
[[["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-05 UTC."],[],[],null,["# Getting a Cloud KMS resource ID\n\nWhen you refer to a Cloud Key Management Service resource using the Cloud KMS API or Google Cloud CLI, you use the resource ID. For example, you can use the resource\nID of a key ring to grant an\n[Identity and Access Management (IAM) role](/kms/docs/reference/permissions-and-roles) on\nthat key ring. This topic shows how to get the ID for a key ring, a key, and a\nkey version.\n\nGetting the resource ID for a key ring\n--------------------------------------\n\n### Console\n\n1. Go to the **Key Management** page in the Google Cloud console.\n\n [Go to\n the Key Management page](https://console.cloud.google.com/security/kms)\n2. Click **More** *more_vert*\n for the key ring.\n\n3. Click **Copy resource name**. The resource ID for the key ring is copied to your\n clipboard.\n\n### gcloud\n\nList all key rings in a location: \n\n```\ngcloud kms keyrings list --location LOCATION\n```\n\nThe **Name** column of the output includes the resource ID for each key ring.\nFor example: \n\n```\nprojects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING\n```\n\nGetting the ID for a key and version\n------------------------------------\n\n### Console\n\n1. Go to the **Key Management** page in the Google Cloud console.\n\n [Go to\n the Key Management page](https://console.cloud.google.com/security/kms)\n2. Select the key ring that contains the key.\n\n3. For the key whose resource ID you are retrieving, click\n **More** *more_vert*.\n\n4. Click **Copy resource name**. The resource ID for the key is copied to your\n clipboard. Its format is similar to the following:\n\n ```\n projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME\n ```\n5. A key contains zero or more key versions. The resource ID for a key\n version is the key ID, plus a slash (`/`), plus the version ID. To list\n all versions for a key, click the key's name. Click the **More** icon for\n the version, and click **Copy resource name**.\n\n### gcloud\n\nList all keys on a given key ring: \n\n```\ngcloud kms keys list --keyring KEY_RING --location LOCATION\n```\n\nThe **Name** column of the output includes the resource ID for each key. For\nexample: \n\n```\nprojects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME\n```\n\nA key has zero or more key versions. The resource ID for a key version is\nthe key ID, plus a slash (`/`), plus the version ID. To list all versions\nfor a key: \n\n```\ngcloud kms keys versions list --location LOCATION --keyring KEY_RING --key KEY_NAME\n```\n\nThe **Name** column of the output includes the resource ID for each key\nversion. For example: \n\n```\nprojects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME/2\n```\n\nWhat's next\n-----------\n\n- Learn more about [permissions and roles](/kms/docs/reference/permissions-and-roles) in Cloud KMS.\n- [Manage access to Cloud KMS resources](/kms/docs/iam).\n- [Rotate a key](/kms/docs/rotate-key)."]]