Question 580 of 1,740
Security and CompliancehardMultiple ChoiceObjective-mapped

Quick Answer

The correct approach is to attach an IAM role to the EC2 instance and use the instance profile to obtain temporary credentials from the instance metadata service. This works because the instance metadata service (IMDS) at http://169.254.169.254/latest/meta-data/iam/security-credentials/ provides automatically rotating temporary credentials on-demand, ensuring they are never written to disk. On the AWS Certified DevOps Engineer Professional DOP-C02 exam, this scenario tests your understanding of how to grant an EC2 instance an IAM role for S3 access without hardcoding secrets—a common trap is choosing to store access keys in a configuration file or using environment variables, which violates the "never stored on disk" rule. The key insight is that instance profiles decouple credentials from the instance, relying on AWS's automatic rotation every time the token expires. Memory tip: think "IMDS, not disks"—the metadata service is the only way to get fresh, diskless credentials.

DOP-C02 Security and Compliance Practice Question

This DOP-C02 practice question tests your understanding of security and compliance. Match the stated requirement to the specific cloud service, access model, or configuration option — many options are valid in isolation but not for this scenario. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

A company is running a critical application on an Amazon EC2 instance that needs to access an S3 bucket. The application must use temporary credentials that automatically rotate. The DevOps engineer must ensure that the credentials are never stored on disk. Which approach meets these requirements?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "never"

    Why it matters: Absolute qualifier. True only if the statement has zero exceptions — be cautious of options that seem obvious but break down in edge cases.

Question 1hardmultiple choice
Full question →

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

Attach an IAM role to the EC2 instance and use the instance profile to obtain temporary credentials from the instance metadata service.

Option B is correct because attaching an IAM role to the EC2 instance and using the instance profile allows the application to obtain temporary credentials from the EC2 instance metadata service (IMDS). These credentials are automatically rotated by AWS before they expire, and they are never stored on disk—they are fetched on-demand from the metadata endpoint (http://169.254.169.254/latest/meta-data/iam/security-credentials/). This satisfies both the requirement for automatic rotation and the prohibition against disk storage.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

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

  • Store the credentials in AWS Secrets Manager and retrieve them at application startup.

    Why it's wrong here

    Retrieving from Secrets Manager requires credentials to access Secrets Manager, leading to a chicken-and-egg problem.

  • Attach an IAM role to the EC2 instance and use the instance profile to obtain temporary credentials from the instance metadata service.

    Why this is correct

    Instance profiles provide temporary credentials that are automatically rotated and never stored on disk.

    Clue confirmation

    The clue word "never" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Use AWS Systems Manager Parameter Store to store the credentials and retrieve them using the EC2 instance's IAM role.

    Why it's wrong here

    The instance role can access Parameter Store, but the credentials themselves are not automatically rotated.

  • Generate an access key and secret key for an IAM user and store them in a configuration file on the EC2 instance.

    Why it's wrong here

    Access keys are long-term credentials and storing them on disk is insecure.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates may confuse AWS Secrets Manager or Parameter Store with a solution for automatic credential rotation, not realizing that those services store static secrets unless explicitly configured with rotation via Lambda, whereas an IAM instance profile inherently provides automatically rotating temporary credentials without any disk storage.

Detailed technical explanation

How to think about this question

The EC2 instance metadata service (IMDSv2, using a PUT request for a session token) provides temporary security credentials from the instance profile's IAM role, which are valid for a default duration of 6 hours and are automatically refreshed by the AWS SDKs before expiry. Under the hood, the AWS SDKs call the IMDS endpoint to fetch new credentials when the current ones are about to expire, ensuring zero-touch rotation without any application-level credential management. In a real-world scenario, this approach is critical for compliance with security standards like PCI DSS or SOC 2, which prohibit storing long-term credentials on disk.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A media company stores terabytes of video archives that are accessed once a year for audit purposes. Moving these objects to a cold storage tier (Azure Archive, S3 Glacier, or Google Nearline) costs a fraction of hot storage. Questions like this test whether you understand storage tiers, access frequency tradeoffs, and retrieval latency requirements.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related DOP-C02 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free DOP-C02 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this DOP-C02 question test?

Security and Compliance — This question tests Security and Compliance — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Attach an IAM role to the EC2 instance and use the instance profile to obtain temporary credentials from the instance metadata service. — Option B is correct because attaching an IAM role to the EC2 instance and using the instance profile allows the application to obtain temporary credentials from the EC2 instance metadata service (IMDS). These credentials are automatically rotated by AWS before they expire, and they are never stored on disk—they are fetched on-demand from the metadata endpoint (http://169.254.169.254/latest/meta-data/iam/security-credentials/). This satisfies both the requirement for automatic rotation and the prohibition against disk storage.

What should I do if I get this DOP-C02 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Are there clue words in this question I should notice?

Yes — watch for: "never". Absolute qualifier. True only if the statement has zero exceptions — be cautious of options that seem obvious but break down in edge cases.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

1 more ways this is tested on DOP-C02

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A developer needs to allow an EC2 instance to read from an S3 bucket. Which is the most secure way to grant this access?

easy
  • A.Use the root user credentials of the AWS account.
  • B.Store AWS access keys in the instance's user data and use them in the application.
  • C.Create an S3 bucket policy that allows the EC2 instance's public IP address.
  • D.Create an IAM role with an S3 read policy and attach it to the EC2 instance profile.

Why D: Option A is correct because an IAM role attached to the EC2 instance allows temporary credentials without hardcoding keys. Option B is wrong because storing keys in the instance is insecure. Option C is wrong because root credentials are highly privileged and should never be used. Option D is wrong because resource-based policies on S3 can grant access to IAM roles, but the role must still be attached to the instance.

Last reviewed: Jun 11, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This DOP-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 DOP-C02 exam.