Secret Manager は、REST API と gRPC API を公開し、直接またはアプリケーション内でシークレットを使用、管理します。このページでは、Secret Manager を初めて使用する際に、Secret Manager API を有効にし、 Google Cloud プロジェクトを構成する方法について説明します。
At the bottom of the Google Cloud console, a
Cloud Shell
session starts and displays a command-line prompt. Cloud Shell is a shell environment
with the Google Cloud CLI
already installed and with values already set for
your current project. It can take a few seconds for the session to initialize.
gcloud セッションで Google Cloud プロジェクトを設定するには、gcloud config set project コマンドを実行します。PROJECT_ID は、実際の Google Cloud プロジェクト ID に置き換えます。
[[["わかりやすい","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-04 UTC。"],[],[],null,["# Enable the Secret Manager API\n\nSecret Manager exposes a REST API and a gRPC API for using and managing secrets\ndirectly or in your applications. This page describes how to enable the\nSecret Manager API and configure your Google Cloud project to use\nSecret Manager for the first time.\n\nThis step is a prerequisite for all tasks in Secret Manager, including the\n[quickstart](/secret-manager/docs/quickstart).\n\nWhen you are becoming familiar with Secret Manager, we recommend using a\nseparate Google Cloud project. Deleting the project also deletes all\nresources created during testing, including billable resources.\n\nIf you are developing an application in an IDE with [Cloud Code](https://cloud.google.com/code) installed,\nSecret Manager comes integrated into the extension. This means that you\ncan create, view, update, and use secrets without having to leave your IDE. For\nmore on using Secret Manager with Cloud Code, refer to the secret\nmanaging guide for your preferred IDE,\n[VS Code](/code/docs/vscode/secret-manager),\n[IntelliJ](/code/docs/intellij/secret-manager),\nor [Cloud Shell Editor](/code/docs/shell/secret-manager).\n\nBefore you begin\n----------------\n\n1. In the Google Cloud console, go to the project selector page.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n2. Select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\nEnable the Secret Manager API\n-----------------------------\n\n### Console\n\n1. In the Google Cloud console, go to the **Secret Manager API** page.\n\n [Go to Secret Manager API](https://console.cloud.google.com/apis/library/secretmanager.googleapis.com)\n2. Verify that the name of your project appears in the project selector at the top of the page.\n\n If you don't see the name of your project, click the project selector, and then select your project.\n3. Click **Enable**.\n\n### gcloud\n\n1. In the Google Cloud console, activate Cloud Shell.\n\n [Activate Cloud Shell](https://console.cloud.google.com/?cloudshell=true)\n\n\n At the bottom of the Google Cloud console, a\n [Cloud Shell](/shell/docs/how-cloud-shell-works)\n session starts and displays a command-line prompt. Cloud Shell is a shell environment\n with the Google Cloud CLI\n already installed and with values already set for\n your current project. It can take a few seconds for the session to initialize.\n2. To set your Google Cloud project in the gcloud session, run the [`gcloud config set project`](/sdk/gcloud/reference/config/set) command. Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your Google Cloud project ID. \n\n ```scdoc\n gcloud config set project PROJECT_ID\n ```\n3. To enable the Secret Manager API, run the [`gcloud services enable`](/sdk/gcloud/reference/services/enable) command: \n\n ```text\n gcloud services enable secretmanager.googleapis.com\n ```\n4. To verify that the Secret Manager API is enabled, run the [`gcloud services list`](/sdk/gcloud/reference/services/list) command: \n\n ```text\n gcloud services list --enabled\n ```\n\n Verify that the Secret Manager API is listed in the list of enabled APIs.\n\nConfigure roles and permissions\n-------------------------------\n\n\nTo get the permissions that\nyou need to set up Secret Manager,\n\nask your administrator to grant you the\n\n\n[Secret Manager Admin](/iam/docs/roles-permissions/secretmanager#secretmanager.admin) (`roles/secretmanager.admin`)\nIAM role on the project.\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nYou might also be able to get\nthe required permissions through [custom\nroles](/iam/docs/creating-custom-roles) or other [predefined\nroles](/iam/docs/roles-overview#predefined).\n\nFor more information about the access control for Secret Manager, see\n[Access control with IAM](/secret-manager/docs/access-control).\n\nWhat's next\n-----------\n\n- Learn more about [authentication and access](/secret-manager/docs/authentication) to the Secret Manager API.\n- Learn more about [creating secrets](/secret-manager/docs/creating-and-accessing-secrets).\n- Learn more about [adding a secret version](/secret-manager/docs/add-secret-version)."]]