Courseiva
Security →easyMultiple Choice

DVA-C02 Security Practice Question

An application running on EC2 needs to access an S3 bucket. What is the most secure way to grant access?

⚠ Common exam trap

DVA-C02 often tests credential management — candidates pick access keys stored on the instance because it 'works,' missing that IAM roles provide short-lived, auto-rotated credentials and are the AWS-recommended pattern.

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

✓

Create an IAM role with S3 permissions and attach it to the EC2 instance

Attaching an IAM role to the EC2 instance (D) is the most secure approach because it delivers temporary, automatically rotated credentials to the instance via the Instance Metadata Service (IMDS), eliminating long-lived access keys stored on disk. The role's trust policy allows EC2 to assume it, and the attached permissions policy scopes exactly which S3 actions and resources the instance can access. This follows AWS least-privilege and credential-hygiene best practices.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Generate an IAM user access key and store it in a file on the instance

    Why it's wrong here

    Generating an IAM user access key and storing it directly on the EC2 instance is a severe security anti-pattern. These static, long-lived credentials become a critical vulnerability if the instance is compromised, potentially granting an attacker persistent access to your AWS environment. Furthermore, managing the secure rotation and revocation of these keys across multiple instances introduces significant operational overhead and risk.

  • ✗

    Use pre-signed URLs for each request

    Why it's wrong here

    Using pre-signed URLs for every S3 request from an EC2 instance is highly inefficient and impractical for ongoing application access. Pre-signed URLs are designed to provide temporary, time-limited access to specific S3 objects for unauthenticated users or applications outside your AWS environment. Requiring the EC2 application to constantly request new pre-signed URLs for each operation introduces unnecessary complexity, latency, and management overhead, making it unsuitable for persistent server-side access.

  • ✗

    Make the S3 bucket public

    Why it's wrong here

    Making an S3 bucket publicly accessible grants unrestricted read and/or write access to anyone on the internet, which is a significant security risk. This violates the principle of least privilege and can lead to severe data breaches, unauthorized modifications, or accidental data exposure. Public buckets are generally only appropriate for specific use cases like static website hosting where the content is intentionally public and non-sensitive.

  • ✓

    Create an IAM role with S3 permissions and attach it to the EC2 instance

    Why this is correct

    Creating an IAM role with the necessary S3 permissions and attaching it to the EC2 instance is the secure and recommended best practice. This method allows the EC2 instance to assume the role, obtaining temporary, automatically rotated credentials from the AWS Security Token Service (STS) via the instance metadata service. This eliminates the need to store any long-lived static credentials on the instance, significantly reducing the risk of credential compromise and simplifying credential management.

Quick reference

AWS S3 Storage Class Comparison

Storage ClassMin DurationRetrievalUse Case
S3 StandardNoneImmediateFrequently accessed data
S3 Standard-IA30 daysImmediateInfrequent access, rapid retrieval
S3 One Zone-IA30 daysImmediateNon-critical infrequent data
S3 Intelligent-TieringNoneImmediate–hoursUnknown or changing access patterns
S3 Glacier Instant90 daysMillisecondsArchive with instant retrieval
S3 Glacier Flexible90 daysMinutes–hoursArchive, flexible retrieval
S3 Glacier Deep Archive180 daysHoursLong-term compliance archive

About these practice questions

One of 1,135 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 and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Amazon Web Services exam blueprint

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.