[[["容易理解","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-02 (世界標準時間)。"],[],[],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)."]]