Courseiva
SecuritymediumMultiple SelectObjective-mapped

DVA-C02 Security Practice Question

A developer is using IAM roles to grant permissions to an EC2 instance. Which TWO statements are true about IAM roles for EC2?

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

Temporary security credentials are obtained from the instance metadata service.

An EC2 instance obtains temporary security credentials from the instance metadata service (http://169.254.169.254/latest/meta-data/iam/security-credentials/). Option E is correct because you can attach an IAM role to a running EC2 instance using the AWS CLI or console without stopping the instance. Option A is incorrect because an EC2 instance can have only one IAM role attached at a time (via an instance profile). Option C is incorrect because temporary credentials are automatically refreshed by the AWS SDKs and CLI before they expire (default expiry is 6 hours, but refresh is automatic). Option D is incorrect because the same IAM role can be attached to multiple EC2 instances simultaneously (via the same instance profile).

Answer analysis

Option-by-option breakdown

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

  • An EC2 instance can have multiple IAM roles attached simultaneously.

    Why it's wrong here

    An EC2 instance can only have one instance profile associated with it, and that profile can contain exactly one IAM role. You cannot attach multiple IAM roles simultaneously; instead, you must combine all required permissions into a single role's policy. Swapping roles requires replacing the instance profile on the instance, not attaching an additional one.

  • Temporary security credentials are obtained from the instance metadata service.

    Why this is correct

    When an EC2 instance uses an IAM role, the AWS SDK automatically retrieves temporary security credentials from the EC2 Instance Metadata Service at 169.254.169.254/latest/meta-data/iam/security-credentials/. These credentials are signed with STS and include an AccessKeyId, SecretAccessKey, and Token, and the SDK caches and refreshes them without any access key management on your part.

  • The temporary credentials expire after 6 hours and must be manually refreshed.

    Why it's wrong here

    Temporary credentials obtained from an IAM role have a configurable session duration (default 6 hours, max 6 hours for EC2), but the AWS SDK does not require manual refresh. The SDK detects expiration and transparently calls the instance metadata service to receive a new set of credentials. Behind the scenes, the EC2 service also periodically rotates these credentials, so no human intervention is needed.

  • An IAM role can only be attached to one EC2 instance at a time.

    Why it's wrong here

    An IAM role is not tied to a single instance. The role is contained in an instance profile, and a single instance profile can be associated with many EC2 instances at the same time. Thus, the same IAM role can be used by hundreds of instances concurrently, with each instance getting its own STS session through the metadata service.

  • An IAM role can be attached to a running EC2 instance without stopping it.

    Why this is correct

    You can associate or replace an IAM instance profile on a running EC2 instance without stopping or rebooting it. Using the AWS CLI or Management Console, operations like associate-iam-instance-profile apply the profile immediately, and new processes that fetch credentials will then receive the new role's permissions. This allows you to change access rights on live instances for temporary needs or privilege adjustments.

About these practice questions

Courseiva writes every DVA-C02 question from scratch — 724 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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.