- A
Store credentials in the Cloud Function code as environment variables.
Why wrong: Storing credentials in code or env variables is insecure and not recommended.
- B
Use Cloud Key Management Service to encrypt credentials and pass them via HTTP headers.
Why wrong: Overly complex and not a secure injection pattern.
- C
Use Secret Manager to store and access the database password.
Secret Manager provides secure storage and access control for secrets.
- D
Embed credentials in the database connection string in the source code.
Why wrong: Hardcoding credentials in source code is a security risk.
Quick Answer
The answer is to use Secret Manager to store and access the database password, as this is the simplest and most secure method for injecting Cloud SQL credentials into Cloud Functions. Secret Manager acts as a centralized vault for sensitive data like database passwords, allowing your Cloud Function to retrieve the secret at runtime via the API or by mounting it as a volume, which completely avoids hardcoding credentials in code or environment variables that could be exposed in logs or source control. On the Google Professional Cloud Developer exam, this question tests your understanding of Google Cloud’s recommended security patterns for serverless compute, often appearing as a trap where less secure options like environment variables or Cloud Storage signed URLs seem tempting. The key memory tip is “Secrets, not strings”—always store sensitive database credentials in Secret Manager rather than embedding them as plain text, ensuring your Cloud Function remains both secure and auditable.
PCD Deploying applications Practice Question
This PCD practice question tests your understanding of deploying applications. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
A developer wants to deploy a Cloud Function that connects to a Cloud SQL database. What is the simplest way to securely inject database credentials?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
Use Secret Manager to store and access the database password.
Option C is correct because Secret Manager provides a secure, centralized service for storing sensitive data like database passwords, and the Cloud Function can access the secret at runtime via the Secret Manager API or by mounting it as a volume. This avoids hardcoding credentials in code or environment variables, which can be exposed in logs or source control. It is the simplest and most secure approach recommended by Google Cloud for injecting database credentials into Cloud Functions.
Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Store credentials in the Cloud Function code as environment variables.
Why it's wrong here
Storing credentials in code or env variables is insecure and not recommended.
- ✗
Use Cloud Key Management Service to encrypt credentials and pass them via HTTP headers.
Why it's wrong here
Overly complex and not a secure injection pattern.
- ✓
Use Secret Manager to store and access the database password.
Why this is correct
Secret Manager provides secure storage and access control for secrets.
Related concept
Read the scenario before looking for a memorised answer.
- ✗
Embed credentials in the database connection string in the source code.
Why it's wrong here
Hardcoding credentials in source code is a security risk.
Common exam traps
Common exam trap: answer the scenario, not the keyword
The trap here is that candidates often confuse environment variables (Option A) as a secure method because they are not in source code, but Cisco tests the understanding that environment variables in serverless environments can still be exposed through logs or the console, whereas Secret Manager provides dedicated encryption and access control.
Detailed technical explanation
How to think about this question
Under the hood, Secret Manager stores secrets as encrypted blobs using AES-256 at rest, and access is controlled via IAM roles (e.g., roles/secretmanager.secretAccessor). Cloud Functions can retrieve secrets using the Secret Manager API with a simple HTTP call or by mounting them as a volume in the function's filesystem, which is handled automatically by the Cloud Functions runtime when the secret is referenced in the function's configuration. A real-world scenario is a CI/CD pipeline where the database password must be rotated without redeploying the function; Secret Manager supports versioning, so the function can be updated to reference a new secret version without code changes.
KKey Concepts to Remember
- Read the scenario before looking for a memorised answer.
- Find the constraint that changes the correct option.
- Eliminate answers that are true in general but not in this case.
TExam Day Tips
- Watch for words such as best, first, most likely and least administrative effort.
- Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Real-world example
How this comes up in practice
A company's IT admin needs to give a contractor read-only access to production logs without sharing account credentials. Using role-based access control (RBAC) and temporary scoped permissions — not a permanent shared password — is the correct pattern. Questions like this test whether you can apply least-privilege access across cloud identity services.
What to study next
Got this wrong? Here's your next step.
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
- →
Deploying applications — study guide chapter
Learn the concepts, then practise the questions
- →
Deploying applications practice questions
Targeted practice on this topic area only
- →
All PCD questions
500 questions across all exam domains
- →
Google Professional Cloud Developer study guide
Full concept coverage aligned to exam objectives
- →
PCD practice test guide
How to use practice tests most effectively before exam day
Related practice questions
Related PCD practice-question pages
Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.
Designing highly scalable, available, and reliable cloud-native applications practice questions
Practise PCD questions linked to Designing highly scalable, available, and reliable cloud-native applications.
Building and testing applications practice questions
Practise PCD questions linked to Building and testing applications.
Deploying applications practice questions
Practise PCD questions linked to Deploying applications.
Integrating Google Cloud services practice questions
Practise PCD questions linked to Integrating Google Cloud services.
Managing application performance monitoring practice questions
Practise PCD questions linked to Managing application performance monitoring.
PCD fundamentals practice questions
Practise PCD questions linked to PCD fundamentals.
PCD scenario practice questions
Practise PCD questions linked to PCD scenario.
PCD troubleshooting practice questions
Practise PCD questions linked to PCD troubleshooting.
Practice this exam
Start a free PCD practice session
Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.
FAQ
Questions learners often ask
What does this PCD question test?
Deploying applications — This question tests Deploying applications — Read the scenario before looking for a memorised answer..
What is the correct answer to this question?
The correct answer is: Use Secret Manager to store and access the database password. — Option C is correct because Secret Manager provides a secure, centralized service for storing sensitive data like database passwords, and the Cloud Function can access the secret at runtime via the Secret Manager API or by mounting it as a volume. This avoids hardcoding credentials in code or environment variables, which can be exposed in logs or source control. It is the simplest and most secure approach recommended by Google Cloud for injecting database credentials into Cloud Functions.
What should I do if I get this PCD question wrong?
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
What is the key concept behind this question?
Read the scenario before looking for a memorised answer.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Keep practising
More PCD practice questions
- A company is deploying a microservices architecture on GKE. They need to expose a set of related microservices under a s…
- You need to monitor the CPU usage of a Compute Engine instance and trigger an alert when it exceeds 80% for 5 minutes. W…
- Match each Firebase feature to its description.
- Drag and drop the steps to create a Cloud Run service in the correct order.
- Drag and drop the steps to deploy a containerized application to Google Kubernetes Engine (GKE) in the correct order.
- Drag and drop the steps to set up a Cloud SQL instance with a private IP in the correct order.
Last reviewed: Jun 25, 2026
This PCD practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCD exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.