Gerenciar segredos com o Secret Manager no Cloud Code para IntelliJ
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
O Secret Manager permite evitar o armazenamento de secrets na base do código.
Em vez disso, você os armazena no Secret Manager e os busca
de maneira programática quando necessário. Com a integração do
Secret Manager do Cloud Code, é fácil criar, visualizar,
atualizar e usar secrets.
Nesta página, descrevemos como acessar o Secret Manager no seu ambiente de desenvolvimento integrado
e como começar a criar e gerenciar secrets.
Como ativar o Secret Manager
A chave secreta precisa estar no mesmo projeto que o código do aplicativo e a API Secret Manager precisa estar ativada para o projeto.
Para iniciar o Secret Manager, clique na guia "Secret Manager" na barra lateral direita do Cloud Code ou acesse Ferramentas > Cloud Code > Secret Manager
Se você não ativou a API Secret Manager,
ative-a quando o Cloud Code solicitar. Para isso, clique em
Ativar API.
Como criar e ver secrets
Como criar secrets
É possível criar um secret com um dos seguintes métodos:
Como usar o painel do Secret Manager
Navegue até o painel do Secret Manager.
Clique em + Add.
Na caixa de diálogo "Criar secret", configure seu secret e clique em
OK.
Como usar o editor
Abra um arquivo contendo o texto que você quer armazenar como um secret no editor.
Destaque o texto a ser armazenado como secret, clique com o botão direito do mouse no texto e clique em
Create Secret in Secret Manager.
Na caixa de diálogo "Criar secret", configure seu secret e clique em
OK.
Como usar o explorador de projetos
No explorador de projetos, sem destacar nenhum texto, clique com o botão direito do mouse e, em seguida, clique em Criar secret no Secret Manager.
Na caixa de diálogo "Criar secret", configure seu secret e clique em
OK.
Como criar novas versões de secrets
Para atualizar um secret atual, crie uma nova versão dele:
No painel do Secret Manager, clique com o botão direito do mouse em um secret e depois
em Nova versão.
Na caixa de diálogo "Adicionar nova versão", defina o valor do secret atual usando
o campo "Valor do secret" ou importando um arquivo.
Para remover todas as versões anteriores do secret e manter apenas a nova versão que você está criando, escolha Desativar todas as versões anteriores.
Clique em OK. Sua versão foi adicionada, é possível ver a versão mais recente e, se aplicável, todas as versões do secret listadas na guia "Versões".
Como visualizar secrets
Para ver secrets, no painel do Secret Manager, selecione um secret
na lista exibida na seção Nome do secret. Seus detalhes, como nome, política de
replicação, carimbo de data/hora da criação e código do recurso, são listados na guia "Visão geral".
Para visualizar e gerenciar um secret no seu navegador, clique com o botão direito do mouse no secret e escolha Abrir no console do Cloud.
Como acessar secrets do seu aplicativo
Depois da criação do secret, é possível incluí-la no seu código e configurar a
autenticação.
Para acessar o secret recém-criado no seu aplicativo, siga estas etapas:
No painel do Secret Manager, clique no nome do secret que você quer acessar no código e clique na guia Código.
Clique em Instale a biblioteca de cliente do Secret Manager.
Na página da API Secret Manager, defina o projeto do Google Cloud
e ative-a, caso ainda não
tenha feito isso.
Siga as instruções em Instalar biblioteca de cliente para a linguagem que você está usando.
Se você estiver usando uma conta de serviço, atribua a ela o
papel necessário para acessar o secret do Secret Manager. Para
informações sobre os papéis do IAM disponíveis para o Secret Manager,
consulte o
Guia de controle de acesso do Secret Manager.
Para enviar um feedback ou informar um problema no ambiente de desenvolvimento integrado do IntelliJ, acesse
Tools > Cloud Code > Help / About > Envie
feedback ou informe um problema para informar um problema no GitHub.
[[["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-09-08 UTC."],[[["\u003cp\u003eSecret Manager allows you to store secrets outside of your codebase, enhancing security by fetching them programmatically when needed.\u003c/p\u003e\n"],["\u003cp\u003eYou can enable Secret Manager and create secrets directly within your IDE through the Secret Manager pane, the editor, or the project explorer.\u003c/p\u003e\n"],["\u003cp\u003eUpdating existing secrets involves creating new versions, with the option to disable all past versions to retain only the latest one.\u003c/p\u003e\n"],["\u003cp\u003eSecrets can be viewed with their details in the Overview tab, or they can be opened in the Cloud console for more in-depth management.\u003c/p\u003e\n"],["\u003cp\u003eAccessing secrets within your application involves installing the Secret Manager client library, integrating code snippets, and configuring authentication.\u003c/p\u003e\n"]]],[],null,["# Manage secrets with Secret Manager in Cloud Code for IntelliJ\n\nSecret Manager lets you avoid storing secrets in your codebase.\nInstead, you store them in Secret Manager and fetch them\nprogrammatically when you need them. With Cloud Code's\nSecret Manager integration, you can easily create, view,\nupdate, and use secrets.\n\nThis page describes how to access Secret Manager in your IDE\nand how you can get started creating and managing secrets.\n\nEnabling Secret Manager\n-----------------------\n\nYour secret needs to be in the same project as your application code and\nSecret Manager API needs to be enabled for your project.\n\n1. To launch Secret Manager, click the\n Secret Manager tab in the right Cloud Code\n sidebar or go to **Tools** \\\u003e **Cloud Code** \\\u003e\n **Secret Manager**.\n\n2. If you haven't enabled the Secret Manager API,\n enable it when Cloud Code prompts you by clicking\n **Enable API**.\n\nCreating and viewing secrets\n----------------------------\n\n### Creating secrets\n\nYou can create a secret using one of the following methods:\n\n#### Using the Secret Manager pane\n\n1. Navigate to the Secret Manager pane.\n\n2. Click **+ Add**.\n\n3. In the Create Secret dialog, configure your secret and then click\n **OK**.\n\n#### Using the editor\n\n1. Open a file containing text you would like to store as a secret in the editor.\n2. Highlight the text to store as a secret, right-click the text, and then click **Create Secret in Secret Manager**.\n3. In the Create Secret dialog, configure your secret and then click **OK**.\n\n#### Using the project explorer\n\n1. In the project explorer, without highlighting any text, right-click and then\n click **Create Secret in Secret Manager**.\n\n2. In the Create Secret dialog, configure your secret and then click\n **OK**.\n\n### Creating new versions of secrets\n\nTo update an existing secret, create a new version of the secret:\n\n1. In the Secret Manager pane, right-click a secret and then\n click **New Version**.\n\n2. In the Add new version dialog, set the value of your existing secret by using\n the Secret value field or by importing a file.\n\n3. To remove all previous versions of your secret and keep just the new version\n you're creating, choose **Disable all past versions**.\n\n4. Click **OK**. Your version is added, you can see your latest secret\n version, and if applicable, all the versions of your secret listed on\n the Versions tab.\n\n### Viewing secrets\n\nTo view secrets, in the Secret Manager pane, select a secret\nfrom the list displayed in the Secret Name section. Its details such as name,\nreplication policy, creation timestamp, and resource ID are listed in the\nOverview tab.\n\nTo view and manage a secret in your browser, right-click the secret and then\nchoose **Open in Cloud console**.\n\nAccessing secrets from your application\n---------------------------------------\n\nAfter your secret is created, you can include it in your code and set up\nauthentication.\n\nTo access your newly created secret from your application, follow these steps:\n\n1. In the Secret Manager pane, click the name of the secret you want to access in code and then click the **Code** tab.\n2. Click **Install the Secret Manager client library**.\n3. On the Secret Manager API page, set the Google Cloud project and enable the Secret Manager API if you haven't already.\n4. Follow the instructions under **Install Client Library** for the language you're using.\n5. Customize and include the [relevant code snippet](/secret-manager/docs/access-secret-version) in your application's code.\n6. If you're using a service account, assign your Google service account the role required to access your Secret Manager secret. For information about IAM roles available for Secret Manager, see the [Secret Manager access control guide](/secret-manager/docs/access-control).\n7. To complete your authentication setup, follow the instructions in [Setting up authentication](/code/docs/intellij/client-libraries-ux#setting_up_authentication).\n\nGet support\n-----------\n\nTo submit feedback or report an issue in your IntelliJ IDE, go to **Tools** \\\u003e **Cloud Code** \\\u003e **Help / About** \\\u003e **Submit\nfeedback or report an issue** to report an issue on [GitHub](https://github.com/GoogleCloudPlatform/cloud-code-intellij/issues)."]]