Google Cloud Professional Cloud Developer — Question 81

You want to create `fully baked` or `golden` Compute Engine images for your application. You need to bootstrap your application to connect to the appropriate database according to the environment the application is running on (test, staging, production). What should you do?

Answer options

Correct answer: D

Explanation

Option D is correct because it allows the application to dynamically retrieve the database connection string from the metadata server, which is suitable for different environments without needing separate images. Option A is inefficient as it requires multiple images for each environment. Option B does not leverage the metadata server, making it less flexible. Option C relies on environment variables, which can be less secure and harder to manage than directly querying the metadata server.