Gestire i secret con Secret Manager in Cloud Code for IntelliJ
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Secret Manager ti consente di evitare di archiviare i secret nel codebase.
Invece, li memorizzi in Secret Manager e li recuperi
in modo programmatico quando ne hai bisogno. Con l'integrazione di Secret Manager di Cloud Code, puoi creare, visualizzare, aggiornare e utilizzare facilmente i secret.
Questa pagina descrive come accedere a Secret Manager nel tuo IDE
e come iniziare a creare e gestire i secret.
Abilitazione di Secret Manager
Il secret deve trovarsi nello stesso progetto del codice dell'applicazione e
l'API Secret Manager deve essere abilitata per il progetto.
Per avviare Secret Manager, fai clic sulla scheda
Secret Manager nella barra laterale destra di Cloud Code
oppure vai a Strumenti > Cloud Code >
Secret Manager.
Se non hai abilitato l'API Secret Manager,
abilitala quando Cloud Code ti chiede di farlo facendo clic su
Abilita API.
Creazione e visualizzazione dei secret
Creazione di secret
Puoi creare un secret utilizzando uno dei seguenti metodi:
Utilizzo del riquadro Secret Manager
Vai al riquadro Secret Manager.
Fai clic su + Aggiungi.
Nella finestra di dialogo Crea secret, configura il secret e fai clic su
Ok.
Utilizzo dell'editor
Apri un file contenente il testo che vuoi archiviare come secret nell'editor.
Evidenzia il testo da archiviare come secret, fai clic con il tasto destro del mouse sul testo e poi fai clic su
Crea secret in Secret Manager.
Nella finestra di dialogo Crea secret, configura il secret e fai clic su
Ok.
Utilizzo di Esplora progetti
In Esplora progetti, senza evidenziare alcun testo, fai clic con il tasto destro del mouse e poi
fai clic su Crea secret in Secret Manager.
Nella finestra di dialogo Crea secret, configura il secret e fai clic su
Ok.
Creazione di nuove versioni dei secret
Per aggiornare un secret esistente, crea una nuova versione del secret:
Nel riquadro Secret Manager, fai clic con il tasto destro del mouse su un secret e poi
fai clic su Nuova versione.
Nella finestra di dialogo Aggiungi nuova versione, imposta il valore del secret esistente utilizzando
il campo Valore secret o importando un file.
Per rimuovere tutte le versioni precedenti del secret e conservare solo la nuova versione
che stai creando, scegli Disattiva tutte le versioni precedenti.
Fai clic su OK. La tua versione viene aggiunta, puoi vedere l'ultima versione del secret e, se applicabile, tutte le versioni del secret elencate nella scheda Versioni.
Visualizzare i secret
Per visualizzare i secret, nel riquadro Secret Manager, seleziona un secret
dall'elenco visualizzato nella sezione Nome secret. I dettagli, come nome, norma di replica, timestamp di creazione e ID risorsa, sono elencati nella scheda Panoramica.
Per visualizzare e gestire un secret nel browser, fai clic con il tasto destro del mouse sul secret e poi
scegli Apri nella console Cloud.
Accedere ai secret dalla tua applicazione
Una volta creato il segreto, puoi includerlo nel codice e configurare
l'autenticazione.
Per accedere al segreto appena creato dalla tua applicazione:
Nel riquadro Secret Manager, fai clic sul nome del secret
a cui vuoi accedere nel codice e poi fai clic sulla scheda Codice.
Fai clic su Installa la libreria client di Secret Manager.
Nella pagina dell'API Secret Manager, imposta il progetto Google Cloude abilita l'API Secret Manager, se non l'hai già fatto.
Segui le istruzioni riportate in Installare la libreria client per la lingua
che stai utilizzando.
Se utilizzi un account di servizio, assegna al tuo account di servizio Google il ruolo richiesto per accedere al secret di Secret Manager. Per
informazioni sui ruoli IAM disponibili per Secret Manager,
consulta la
guida al controllo dell'accesso di Secret Manager.
Per completare la configurazione dell'autenticazione, segui le istruzioni riportate in
Configurare l'autenticazione.
Assistenza
Per inviare un feedback o segnalare un problema nel tuo IDE IntelliJ, vai a
Strumenti > Cloud Code > Guida / Informazioni > Invia
feedback o segnala un problema per segnalare un problema su GitHub.
[[["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."],[[["\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)."]]