DVA-C02 Security Practice Question
An application running on EC2 instances needs to access an S3 bucket securely. Which of the following is the BEST practice for managing credentials?
⚠ Common exam trap
It's easy for candidates to confuse IAM users with IAM roles, mistakenly thinking that creating a dedicated IAM user with programmatic access is a secure practice, when in fact IAM roles are the correct and secure method for EC2-to-S3 access because they eliminate the need to manage long-term credentials.
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
✓
Launch the EC2 instance with an IAM role that grants S3 access.
Assigning an IAM role to an EC2 instance is the AWS-recommended best practice for securely granting permissions to AWS services. The instance automatically obtains temporary security credentials from the instance metadata service (IMDS), eliminating the need to hardcode or manage long-term access keys. This approach follows the principle of least privilege and avoids the security risks of storing credentials on disk.
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 AWS access key and secret key in a configuration file on the EC2 instance.
Why it's wrong here
Storing AWS access keys and secret keys directly on an EC2 instance in a configuration file is highly insecure. These are long-term credentials that, if compromised, grant persistent access to your AWS resources, potentially leading to significant data breaches or unauthorized operations. This method violates the principle of least privilege and introduces a critical security vulnerability, as the keys could be exposed through misconfigurations, code vulnerabilities, or unauthorized access to the instance.
- ✗
Use an IAM user with programmatic access and attach a policy allowing S3 access.
Why it's wrong here
While using an IAM user provides granular permissions, assigning an IAM user's programmatic access keys to an application running on an EC2 instance still relies on long-term credentials. These static keys, similar to those stored in a configuration file, must be securely managed, rotated, and protected from exposure. This approach introduces operational overhead and security risks, as a compromise of these keys would grant persistent access to the associated IAM user's permissions, making it an anti-pattern for machine-to-AWS service access.
- ✓
Launch the EC2 instance with an IAM role that grants S3 access.
Why this is correct
Launching an EC2 instance with an IAM role is the AWS best practice for granting applications secure access to AWS services like S3. An IAM role provides temporary security credentials that are automatically rotated and delivered to the instance via the instance metadata service. This eliminates the need to embed or manage long-term access keys on the instance, significantly reducing the risk of credential compromise and simplifying credential management, aligning with the principle of least privilege.
- ✗
Use a shared secret key stored in AWS Secrets Manager and retrieve it at runtime.
Why it's wrong here
While AWS Secrets Manager is excellent for securely storing and rotating database credentials, API keys, or other application secrets, using it to store AWS access keys for an EC2 instance to access S3 introduces unnecessary complexity and an architectural anti-pattern. The EC2 instance would still require *some* initial credentials or an IAM role to access Secrets Manager itself, creating a bootstrapping problem or an indirect reliance on long-term keys. IAM roles for EC2 instances are specifically designed for this exact use case, offering a more direct, secure, and simpler solution without additional service dependencies.
Quick reference
AWS S3 Storage Class Comparison
| Storage Class | Min Duration | Retrieval | Use Case |
|---|---|---|---|
| S3 Standard | None | Immediate | Frequently accessed data |
| S3 Standard-IA | 30 days | Immediate | Infrequent access, rapid retrieval |
| S3 One Zone-IA | 30 days | Immediate | Non-critical infrequent data |
| S3 Intelligent-Tiering | None | Immediate–hours | Unknown or changing access patterns |
| S3 Glacier Instant | 90 days | Milliseconds | Archive with instant retrieval |
| S3 Glacier Flexible | 90 days | Minutes–hours | Archive, flexible retrieval |
| S3 Glacier Deep Archive | 180 days | Hours | Long-term compliance archive |
Go deeper
Related to this question
About these practice questions
This DVA-C02 question is part of Courseiva's 1,135-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
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.