
Answer-first summary for fast verification
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.
To create fully baked (golden) Compute Engine images, the image should be environment-agnostic. Using instance metadata to store the database connection string allows the same image to be reused across environments. The application can retrieve the connection string dynamically by querying the metadata server at runtime. This approach externalizes environment-specific configurations, adhering to best practices for golden images. Option D is correct because metadata is retrieved directly from the metadata server, avoiding the need for environment variables (C) or API calls (B). Option A is incorrect as it hardcodes configurations into separate images, defeating the purpose of a reusable golden image.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
You want to create fully baked or golden Compute Engine images for your application. You need to configure your application to connect to the correct database based on the environment it runs in (test, staging, production). What should you do?
A
Embed the appropriate database connection string in the image. Create a different image for each environment.
B
When creating the Compute Engine instance, add a tag with the name of the database to be connected. In your application, query the Compute Engine API to pull the tags for the current instance, and use the tag to construct the appropriate database connection string.
C
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, read the ג€DATABASEג€ environment variable, and use the value to connect to the appropriate database.
D
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.