AWS DevOps Engineer Professional Practice Test

Disable ads (and more) with a membership for a one time $2.99 payment

Prepare for the AWS DevOps Engineer Professional Test. Enhance your skills with flashcards and multiple-choice questions, each offering hints and explanations. Become exam-ready!

Practice this question and more.


What script should you create to replace the text of a file with the name of the EC2 instance in a CodeDeploy deployment?

  1. A script that connects to the CodeBuild service

  2. A script to call the metadata API

  3. A shell script that fetches instance ID from logs

  4. A script that directly modifies the application code

The correct answer is: A script to call the metadata API

To replace the text of a file with the name of the EC2 instance during a CodeDeploy deployment, a script that calls the metadata API is essential. The AWS EC2 instance metadata service provides a simple and efficient way to obtain information about the instance. This includes crucial details like the instance ID, which can be utilized as the name for updating files within the deployment process. By leveraging the metadata API, the script can make a straightforward HTTP request to the metadata endpoint, allowing it to fetch the instance details without needing specific IAM permissions or connections to other AWS services like CodeBuild. This makes it the most appropriate choice for effectively getting the required instance identification information in a seamless manner during the deployment. While other options may involve indirect methods or additional layers of complexity, using the metadata API offers direct access to the necessary data while simplifying the deployment process. The focus is on obtaining real-time, accurate instance information in a concise manner, making this approach optimal for the given scenario.