Google Professional Cloud Developer Question 208
Select 3Google Cloud PlatformYou are developing a web application that uses Google Cloud Pub/Sub for messaging and Google Cloud Firestore for storing user data. To speed up development and testing, you want to emulate these services locally. Which steps should you take to correctly configure and use these emulated services?
- A
Install the Cloud SDK and use the
gcloud emulatorscommands to start the Pub/Sub and Firestore emulators. - B
Update your application code to use the emulator's endpoints instead of the production endpoints.
- C
Deploy the application to a Google Cloud project first, as emulators cannot be used locally.
- D
Use environment variables to specify the emulator host and port for your application to connect to the emulated services.
- E
Configure IAM roles locally to simulate production-grade authentication with the emulators.
Show answer and explanation
Correct answers: A, B, D
Explanation
To emulate Google Cloud services such as Pub/Sub and Firestore locally, developers must use tools like the Cloud SDK to start the emulators and configure their application to connect to the emulator endpoints using environment variables. This allows for rapid development and testing without incurring costs or relying on a live Google Cloud project. Configuring IAM roles is not necessary for emulators, as they are designed to simplify local development by bypassing certain production requirements.
- A. Correct.
Correct. The Cloud SDK provides the necessary tools to start and manage the Pub/Sub and Firestore emulators locally for development.
- B. Correct.
Correct. When using emulators, your application must point to the emulator's endpoints (e.g., localhost) instead of the production service endpoints.
- C. Incorrect.
Incorrect. Emulators are specifically designed to be used locally for development and testing, without the need to deploy to a cloud project.
- D. Correct.
Correct. Environment variables such as
PUBSUB_EMULATOR_HOSTandFIRESTORE_EMULATOR_HOSTare commonly used to configure connections to the emulators. - E. Incorrect.
Incorrect. While IAM roles are important in production, they are not required for local emulators, as authentication is typically bypassed for simplicity.