arrow_back

Configuring and Using Credentials with Secret Manager

로그인 가입
700개 이상의 실습 및 과정 이용하기

Configuring and Using Credentials with Secret Manager

실습 45분 universal_currency_alt 크레딧 5개 show_chart 입문
info 이 실습에는 학습을 지원하는 AI 도구가 통합되어 있을 수 있습니다.
700개 이상의 실습 및 과정 이용하기

Overview

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.

  1. Sign in to Qwiklabs using an incognito window.

  2. 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.

  3. When ready, click Start lab.

  4. Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.

  5. Click Open Google Console.

  6. 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.

  7. 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.

  1. In the Navigation menu, Select API & Services.
  2. At the top of the page, click + Enable API and Services.
  3. In the search box, enter Secret Manager. You should see one result - the Secret Manager API.
  4. 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.

  1. In the Navigation menu, select Security > Secret Manager.
  2. On the Secret Manager main page, click + Create Secret.
  3. For the Name, enter password.
  4. For the Secret value, enter xyzpdq.
  5. Click + Add Label.
  6. For the Key, enter team.
  7. For the Value, enter acme.
  8. 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.

  1. On the Google Cloud Console title bar, click Activate Cloud Shell (Activate cloud shell icon) to open Cloud Shell.
  2. At the bottom of the page, click Continue. Wait for the Google Cloud Shell machine to provision.
  3. At the Cloud Shell Terminal command line, enter:
gcloud secrets versions access 1 --secret="password"

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:

student_00_7413964b6ab0@cloudshell:~ (qwiklabs-gcp-00-f575f732b85b)$ gcloud secrets versions access 1 --secret=" password" xyzpdqstudent_00_7413964b6ab0@cloudshell:~ (qwiklabs-gcp-00-f575f732b85b)$

Task 4. Create and use a new secret version

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.

  1. 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.
  2. Under Actions, click the More actions menu (i.e., the “three dots” menu) and then click Add New Version.
  3. For the Secret value, enter abc123.
  4. Leave all other values at their default setting, and click Add New Version.

Now, let's use the new secret.

  1. At the Cloud Shell Terminal command line, enter:
gcloud secrets versions access 2 --secret="password"
  1. 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:
student_04_ceff8bd49e59@cloudshell:~ (qwiklabs-gcp-04-60caced57c66)$ gcloud secrets versions access 1 --secret="password" abc123student_04_ceff8bd49e59@cloudshell:~ (qwiklabs-gcp-04-60caced57c66)$
  1. At the command line, try the command again - except this time, for the version, use the latest alias, as shown below:
gcloud secrets versions access latest --secret="password"

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:

student_04_ceff8bd49e59@cloudshell:~ (qwiklabs-gcp-04-60caced57c66)$ gcloud secrets versions access latest --secret="password" abc123student_04_ceff8bd49e59@cloudshell:~ (qwiklabs-gcp-04-60caced57c66)$

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.

  1. 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.
  2. Under Actions, click the More actions menu, and then click Add New Version.
  3. For the Secret value, enter def123.
  4. Select the Disable all past versions checkbox.
  5. Leave all other values at their default setting, and click Add New Version.
  6. Verify that only the latest version is accessible. To do so, at the Cloud Shell Terminal command line, enter:
gcloud secrets versions access latest --secret="password"
  1. 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:
student_04_ceff8bd49e59@cloudshell:~ (qwiklabs-gcp-04-60caced57c66)$ gcloud secrets versions access latest --secret="password" def123student_04_ceff8bd49e59@cloudshell:~ (qwiklabs-gcp-04-60caced57c66)$
  1. At the command line, try the command again - except this time, for the version, use the latest alias, as shown below:
gcloud secrets versions access 2 --secret="password"

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.

  1. 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.
  2. Click the password secret. The Details page for the password secret appears.
  3. 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.
  4. For the version 2, under Actions, click the More actions menu, and then select Enable.
  5. Click Enable Selected Versions. In the Status column, version 2 should now appear as enabled.
  6. At the Cloud Shell Terminal command line, enter:
gcloud secrets versions access 2 --secret="password"

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:

student_04_ceff8bd49e59@cloudshell:~ (qwiklabs-gcp-04-60caced57c66)$ gcloud secrets versions access 2 --secret="password" abc123student_04_ceff8bd49e59@cloudshell:~ (qwiklabs-gcp-04-60caced57c66)$
  1. In the upper right corner of Google Console Manager, find and click on the user icon.
  2. Click Sign out.

Review

In this lab you did the following:

  1. Enabled the Secret Manager API.

  2. Created and used a new secret.

  3. Created a new version of a secret.

  4. Disabled the older version(s).

  5. 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.

시작하기 전에

  1. 실습에서는 정해진 기간 동안 Google Cloud 프로젝트와 리소스를 만듭니다.
  2. 실습에는 시간 제한이 있으며 일시중지 기능이 없습니다. 실습을 종료하면 처음부터 다시 시작해야 합니다.
  3. 화면 왼쪽 상단에서 실습 시작을 클릭하여 시작합니다.

시크릿 브라우징 사용

  1. 실습에 입력한 사용자 이름비밀번호를 복사합니다.
  2. 비공개 모드에서 콘솔 열기를 클릭합니다.

콘솔에 로그인

    실습 사용자 인증 정보를 사용하여
  1. 로그인합니다. 다른 사용자 인증 정보를 사용하면 오류가 발생하거나 요금이 부과될 수 있습니다.
  2. 약관에 동의하고 리소스 복구 페이지를 건너뜁니다.
  3. 실습을 완료했거나 다시 시작하려고 하는 경우가 아니면 실습 종료를 클릭하지 마세요. 이 버튼을 클릭하면 작업 내용이 지워지고 프로젝트가 삭제됩니다.

현재 이 콘텐츠를 이용할 수 없습니다

이용할 수 있게 되면 이메일로 알려드리겠습니다.

감사합니다

이용할 수 있게 되면 이메일로 알려드리겠습니다.

한 번에 실습 1개만 가능

모든 기존 실습을 종료하고 이 실습을 시작할지 확인하세요.

시크릿 브라우징을 사용하여 실습 실행하기

이 실습을 실행하려면 시크릿 모드 또는 시크릿 브라우저 창을 사용하세요. 개인 계정과 학생 계정 간의 충돌로 개인 계정에 추가 요금이 발생하는 일을 방지해 줍니다.