
Answer-first summary for fast verification
Answer: In each project, configure a metadata key ג€environmentג€ whose value is the environment it serves. Use your deployment tool to query the instance metadata and configure the application based on the ג€environmentג€ value.
The goal is to configure instances with environment-specific settings while minimizing deployment steps. Option B suggests setting a project-level metadata key 'environment' once per project. All instances in that project inherit this metadata, allowing the deployment tool to query it without per-instance setup. This approach is efficient as it avoids repetitive configuration during instance creation (unlike D) and doesn't rely on project naming conventions (unlike A). Option C adds unnecessary complexity by requiring a separate deployment tool and version control integration. Thus, B is optimal for minimizing steps by leveraging project-wide metadata.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
You are developing an application that will be deployed on Compute Engine instances across multiple distinct projects, each representing a different environment in your software development lifecycle (development, QA, staging, and production). The instances in each project run the same application code but require environment-specific configurations. During deployment, each instance should automatically receive the appropriate configuration for its environment. How can you achieve this with minimal configuration steps?
A
When creating your instances, configure a startup script using the gcloud command to determine the project name that indicates the correct environment.
B
In each project, configure a metadata key ג€environmentג€ whose value is the environment it serves. Use your deployment tool to query the instance metadata and configure the application based on the ג€environmentג€ value.
C
Deploy your chosen deployment tool on an instance in each project. Use a deployment job to retrieve the appropriate configuration file from your version control system, and apply the configuration when deploying the application on each instance.
D
During each instance launch, configure an instance custom-metadata key named ג€environmentג€ whose value is the environment the instance serves. Use your deployment tool to query the instance metadata, and configure the application based on the ג€environmentג€ value.