Courseiva
Development with AWS ServiceseasyMultiple ChoiceObjective-mapped

DVA-C02 Development with AWS Services Practice Question

A developer is writing a script to programmatically create an Amazon EC2 instance. The script will run on an EC2 instance that already has an IAM role attached. Which AWS SDK method should the developer use to securely obtain temporary credentials for the script?

⚠ Common exam trap

Candidates often confuse the AWS SDK's automatic credential resolution (the default credential provider chain) with an explicit method to retrieve credentials, leading them to choose option D even though the question asks for the method the developer should use in the script, which is directly querying the instance metadata endpoint.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Retrieve the temporary credentials from the instance metadata endpoint (http://169.254.169.254/latest/meta-data/iam/security-credentials/).

The instance metadata endpoint at http://169.254.169.254/latest/meta-data/iam/security-credentials/ provides temporary, automatically rotated credentials for the IAM role attached to the EC2 instance. The AWS SDK's default credential provider chain automatically checks this endpoint, but explicitly retrieving from the metadata service is a valid and secure method when you need direct access to the credentials, such as for use with non-AWS tools or custom signing logic.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Retrieve the temporary credentials from the instance metadata endpoint (http://169.254.169.254/latest/meta-data/iam/security-credentials/).

    Why this is correct

    Instance metadata provides temporary credentials from the IAM role automatically.

  • Store the access key ID and secret access key in the script.

    Why it's wrong here

    Hardcoding credentials is insecure and not a best practice.

  • Use AWS Secrets Manager to store and retrieve the credentials.

    Why it's wrong here

    Secrets Manager is for storing secrets, not automatic retrieval of instance role credentials.

  • Use the AWS SDK's default credential provider chain.

    Why it's wrong here

    While the default chain can retrieve instance metadata, the question asks for a specific method.

About these practice questions

One of 724 original DVA-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.