In this lab, you use Secret Manager from Cloud Console and the Command Line Interface (CLI) to create and use a secret, replace a secret, and finally, reinstate an older version of a secret.
Secret Manager is available in Cloud Console. It is also available from the command line using the CLI or from a program, using the REST API or one of the supported Software Development Kits (SDKs). Supported SDKs include C#, Go, Node.js, Java, etc. A complete list of available SDKs. Information regarding the REST API.
Objectives
In this lab, you learn to:
Enable the Secret Manager API.
Create and use a new secret.
Create a new version of a secret, and disable the old version(s).
Reinstate and verify an older version of a secret.
Setup and requirements
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Sign in to Qwiklabs using an incognito window.
Note the lab's access time (for example, 1:15:00), and make sure you can finish within that time.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
When ready, click Start lab.
Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.
Click Open Google Console.
Click Use another account and copy/paste credentials for this lab into the prompts.
If you use other credentials, you'll receive errors or incur charges.
Accept the terms and skip the recovery resource page.
Task 1. Enable the Secret Manager API
In this task, you enable the Secret Manager API.
Before you access Secret Manager, you must first enable its API. If you fail to do so, when you attempt to access its features, you will receive an error.
In the Navigation menu, Select API & Services.
At the top of the page, click + Enable API and Services.
In the search box, enter Secret Manager. You should see one result - the Secret Manager API.
Click Secret Manager API. On the resulting page, click Enable. If no error occurs - and you see a page with information about this API, you were successful.
Click Check my progress to verify the objective.
Enable the Secret Manager API
Task 2. Create a secret
In this task, you create a secret and add the secret value to the password.
In the Navigation menu, select Security > Secret Manager.
On the Secret Manager main page, click + Create Secret.
For the Name, enter password.
For the Secret value, enter xyzpdq.
Click + Add Label.
For the Key, enter team.
For the Value, enter acme.
Leave all other values at their default setting, and click Create Secret.
Click Check my progress to verify the objective.
Create a secret
Task 3. Use a secret
In this task, you use the secrets command to verify the value of the password secret.
On the Google Cloud Console title bar, click Activate Cloud Shell () to open Cloud Shell.
At the bottom of the page, click Continue. Wait for the Google Cloud Shell machine to provision.
If successful, you should see that the value of the password secret (xyzpdq) is returned at the beginning of the next line, immediately before the command line prompt, similar to what is shown below:
In this task, you create a new version 2 secret and use the secrets command to verify the version 2 value of the password secret.
In the Navigation menu of Google Cloud Console, select Security > Secret Manager. The Secret Manager page shows information about the password secret that you created earlier.
Under Actions, click the More actions menu (i.e., the “three dots” menu) and then click Add New Version.
For the Secret value, enter abc123.
Leave all other values at their default setting, and click Add New Version.
If successful, you should see that the value of the password secret (abc123) is returned at the beginning of the next line, immediately before the command line prompt, similar to what is shown in the screenshot below:
If successful, you should see that the version 2 value of the password secret (abc123) is returned at the beginning of the next line, immediately before the command line prompt, similar to what is shown in the screenshot below:
Click Check my progress to verify the objective.
Create and use a new secret version
Task 5. Create a new secret version (and invalidate previous versions)
In this task, you create a new secret version and disable all the past versions. You also verify that only the latest version is accessible.
In the Navigation menu of Google Cloud Console, select Security > Secret Manager. The Secret Manager page shows information about the password secret that you created earlier.
Under Actions, click the More actions menu, and then click Add New Version.
For the Secret value, enter def123.
Select the Disable all past versions checkbox.
Leave all other values at their default setting, and click Add New Version.
Verify that only the latest version is accessible. To do so, at the Cloud Shell Terminal command line, enter:
If successful, you should see that the value of the password secret (def123) is returned at the beginning of the next line, immediately before the command line prompt, similar to what is shown in the screenshot below:
This should produce a FAILED PRECONDITION error, informing you that version 2 is in the DISABLED state. (If you tried to access version 1, the same error would be produced.)
Click Check my progress to verify the objective.
Create a new secret version (and invalidate previous versions)
Task 6. Reinstate and verify a previous secret version
In this task, you re-enable the version 2 password secret and verify that the version 2 password secret is accessible.
In the Navigation menu of Google Cloud Console, select Security > Secret Manager. The Secret Manager page shows information about the password secret that you created earlier.
Click the password secret. The Details page for the password secret appears.
On the Details page, note that all three versions are shown. In the Status column, you see that version 3 is enabled and versions 1 and 2 are disabled.
For the version 2, under Actions, click the More actions menu, and then select Enable.
Click Enable Selected Versions. In the Status column, version 2 should now appear as enabled.
If successful, you should see that the version 2 value of the password secret (abc123) is returned at the beginning of the next line, immediately before the command line prompt, similar to what is shown below:
In the upper right corner of Google Console Manager, find and click on the user icon.
Click Sign out.
Review
In this lab you did the following:
Enabled the Secret Manager API.
Created and used a new secret.
Created a new version of a secret.
Disabled the older version(s).
Reinstated and verified the older version of a secret.
End your lab
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
1 star = Very dissatisfied
2 stars = Dissatisfied
3 stars = Neutral
4 stars = Satisfied
5 stars = Very satisfied
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
Les ateliers créent un projet Google Cloud et des ressources pour une durée déterminée.
Les ateliers doivent être effectués dans le délai imparti et ne peuvent pas être mis en pause. Si vous quittez l'atelier, vous devrez le recommencer depuis le début.
En haut à gauche de l'écran, cliquez sur Démarrer l'atelier pour commencer.
Utilisez la navigation privée
Copiez le nom d'utilisateur et le mot de passe fournis pour l'atelier
Cliquez sur Ouvrir la console en navigation privée
Connectez-vous à la console
Connectez-vous à l'aide des identifiants qui vous ont été attribués pour l'atelier. L'utilisation d'autres identifiants peut entraîner des erreurs ou des frais.
Acceptez les conditions d'utilisation et ignorez la page concernant les ressources de récupération des données.
Ne cliquez pas sur Terminer l'atelier, à moins que vous n'ayez terminé l'atelier ou que vous ne vouliez le recommencer, car cela effacera votre travail et supprimera le projet.
Ce contenu n'est pas disponible pour le moment
Nous vous préviendrons par e-mail lorsqu'il sera disponible
Parfait !
Nous vous contacterons par e-mail s'il devient disponible
Un atelier à la fois
Confirmez pour mettre fin à tous les ateliers existants et démarrer celui-ci
Utilisez la navigation privée pour effectuer l'atelier
Ouvrez une fenêtre de navigateur en mode navigation privée pour effectuer cet atelier. Vous éviterez ainsi les conflits entre votre compte personnel et le compte temporaire de participant, qui pourraient entraîner des frais supplémentaires facturés sur votre compte personnel.
In this lab exercise, you will use Secret Manager from Google Cloud Console and also the CLI.
Durée :
0 min de configuration
·
Accessible pendant 45 min
·
Terminé après 45 min