ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 133 - Professional Cloud DevOps Engineer discussion

Report
Export

You are deploying an application to Cloud Run. The application requires a password to start. Your organization requires that all passwords are rotated every 24 hours, and your application must have the latest password. You need to deploy the application with no downtime. What should you do?

A.
Store the password in Secret Manager and send the secret to the application by using environment variables.
Answers
A.
Store the password in Secret Manager and send the secret to the application by using environment variables.
B.
Store the password in Secret Manager and mount the secret as a volume within the application.
Answers
B.
Store the password in Secret Manager and mount the secret as a volume within the application.
C.
Use Cloud Build to add your password into the application container at build time. Ensure that Artifact Registry is secured from public access.
Answers
C.
Use Cloud Build to add your password into the application container at build time. Ensure that Artifact Registry is secured from public access.
D.
Store the password directly in the code. Use Cloud Build to rebuild and deploy the application each time the password changes.
Answers
D.
Store the password directly in the code. Use Cloud Build to rebuild and deploy the application each time the password changes.
Suggested answer: B

Explanation:

The correct answer is B. Store the password in Secret Manager and mount the secret as a volume within the application.

Secret Manager is a service that allows you to securely store and manage sensitive data such as passwords, API keys, certificates, and tokens. You can use Secret Manager to rotate your secrets automatically or manually, and access them from your Cloud Run applications1.

There are two ways to use secrets from Secret Manager in Cloud Run:

As environment variables: You can set environment variables that point to secrets in Secret Manager. Cloud Run will resolve the secrets at runtime and inject them into the environment of your application. However, this method has some limitations, such as:

The environment variables are cached for up to 10 minutes, so you may not get the latest version of the secret immediately.

The environment variables are visible in plain text in the Cloud Console and the Cloud SDK, which may expose sensitive information.

The environment variables are limited to 4 KB of data, which may not be enough for some secrets.2

As file system volumes: You can mount secrets from Secret Manager as files in a volume within your application. Cloud Run will create a tmpfs volume and write the secrets as files in it. This method has some advantages, such as:

The files are updated every 30 seconds, so you can get the latest version of the secret faster.

The files are not visible in the Cloud Console or the Cloud SDK, which provides better security.

The files can store up to 64 KB of data, which allows for larger secrets.3

Therefore, for your use case, it is better to use the second method and mount the secret as a file system volume within your application. This way, you can ensure that your application has the latest password, and you can deploy it with no downtime.

To mount a secret as a file system volume in Cloud Run, you can use the following command:

gcloud beta run deploy SERVICE --image IMAGE_URL --update-secrets=/path/to/file=secretName:version

where:

SERVICE is the name of your Cloud Run service.

IMAGE_URL is the URL of your container image.

/path/to/file is the path where you want to mount the secret file in your application.

secretName is the name of your secret in Secret Manager.

You can also use the Cloud Console to mount secrets as file system volumes. For more details, see Mounting secrets from Secret Manager.

1: Overview | Secret Manager Documentation | Google Cloud

2: Using secrets as environment variables | Cloud Run Documentation | Google Cloud

3: Mounting secrets from Secret Manager | Cloud Run Documentation | Google Cloud

asked 18/09/2024
DATA 7 DATA7
41 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first