GOOGLE-PROFESSIONAL-CLOUD-DEVELOPER practice question 24 of 35

Your application is built as a custom machine image. You have multiple unique deployments of the machine image. Each deployment is a separate managed…

Full set: 265 questions
Your application is built as a custom machine image. You have multiple unique deployments of the machine image. Each deployment is a separate managed instance group with its own template. Each deployment requires a unique set of configuration values. You want to provide these unique values to each deployment but use the same custom machine image in all deployments. You want to use out-of-the-box features of Compute Engine. What should you do?
Answer options
A: Place the unique configuration values in the persistent disk.
B: Place the unique configuration values in a Cloud Bigtable table.
C: Place the unique configuration values in the instance template startup script.
D: Place the unique configuration values in the instance template instance metadata. Correct answer
Correct Answer:
D. Place the unique configuration values in the instance template instance metadata.
Explanation

Instance metadata is the standard, out-of-the-box Compute Engine feature for providing configuration data to virtual machine instances. Since each deployment uses a unique instance template, you can define a unique set of key-value pairs as custom metadata within each template. The application running on the instance, which is created from the common custom image, can then query the metadata server at runtime to retrieve its specific configuration values. This approach cleanly separates the configuration from the application image, satisfying all requirements of the scenario.

Why Incorrect

A. Persistent disks are for block storage, not for injecting configuration values. This method is inefficient and overly complex for passing configuration data.
B. Cloud Bigtable is an external database service. While it can store configuration, it is not a core feature of Compute Engine for instance configuration and adds unnecessary external dependencies.
C. A startup script is used for running commands at boot time. While it could contain configuration values, the best practice is to store the values in metadata and use the script to read and apply them. ---

References

1. Google Cloud Documentation - Storing and retrieving instance metadata: "Use the metadata server to access information about your instance programmatically, such as the instance's host name, instance ID, startup scripts, and custom metadata... For example, you can write a startup script that gets a metadata key-value pair and uses that value to configure your application." This confirms metadata is the intended mechanism for providing configuration values that can be used by scripts or applications.

Source: Google Cloud > Compute Engine > Documentation > Metadata > Storing and retrieving instance metadata.

2. Google Cloud Documentation - Instance templates: "An instance template is a resource that you can use to create VM instances and managed instance groups (MIGs)... An instance template includes... other instance properties like metadata and startup scripts." This confirms that metadata is a property of the instance template, allowing for unique metadata per template.

Source: Google Cloud > Compute Engine > Documentation > Instance groups > Instance templates.

3. Google Cloud Documentation - Passing metadata to VMs: "You can pass custom metadata to your project or instance... For example, you could create an instance and set a custom metadata value of startup-script-url to specify the location of a startup script." This illustrates the direct use of metadata for configuration.

Source: Google Cloud > Compute Engine > Documentation > VM instances > Creating and starting a VM instance > Passing metadata to VMs.

Scroll to Top