You create golden Compute Engine images but need the app to select the correct database per environment (test/staging/prod). How should you supply the DB connection info at instance boot?
Choose an answer
Tap an option to check your answer.
Correct answer: When creating the Compute Engine instance, create a metadata item with a key of DATABASE and a value for the appropriate database connection string. In your application, query the metadata server for the DATABASE value, and use the value to connect to the appropriate database..
Why this is the answer
The correct answer leverages Compute Engine metadata, a standard and secure way to provide instance-specific configuration. The application queries the instance's metadata server to retrieve the DATABASE value, which contains the connection string. This approach keeps sensitive information out of the image and allows for dynamic configuration per instance. Embedding the connection string in the image (first option) is inflexible and requires maintaining multiple images, which is inefficient. Using instance tags (second option) is not ideal for storing connection strings; tags are primarily for organizing and filtering resources, and querying the Compute Engine API from the application for this purpose adds unnecessary complexity and potential permission issues. While setting an environment variable (third option) is a common pattern, the prompt specifically mentions creating a metadata item, and the most direct way for an application to access metadata is by querying the metadata server, not relying on it being automatically exposed as an environment variable without explicit configuration.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed