Courseiva

SCS-C02 Identity and Access Management Practice Question

A security engineer needs to allow an application running on an Amazon EC2 instance to access an Amazon S3 bucket. The application must not use long-term credentials. The engineer has created an IAM role with the necessary permissions and attached it to the instance profile. However, the application is still receiving access denied errors. Upon investigation, the engineer finds that the application is using the AWS SDK for Java and is explicitly setting credentials via environment variables. What is the MOST likely cause of the access denied errors?

⚠ Common exam trap

The trap here is assuming that attaching an IAM role to an EC2 instance automatically overrides any manually configured credentials, when in fact explicit environment variables take precedence in the SDK's credential provider chain.

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

✓

The environment variables contain credentials that are expired or lack the necessary permissions.

The AWS SDK credential provider chain checks environment variables before instance profile credentials. If the application sets AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, those credentials are used exclusively. If they are expired or lack permissions, access is denied. The solution is to remove the environment variables so the SDK uses the instance profile's temporary credentials.

Answer analysis

Option-by-option breakdown

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

  • ✗

    The IAM role's trust policy does not allow the EC2 service to assume the role.

    Why it's wrong here

    If the trust policy did not allow EC2 to assume the role, the instance profile attachment would fail or the role would not be assumable, but the scenario states the role is attached and the application is running. The explicit environment variable credentials override the instance profile, so the trust policy is not the primary issue.

  • ✓

    The environment variables contain credentials that are expired or lack the necessary permissions.

    Why this is correct

    When environment variables are set, the AWS SDK prioritizes them over the instance profile credentials. If those credentials are expired or have insufficient permissions, the application will receive access denied errors even though the instance profile role has the correct permissions. The SDK does not fall back to the instance profile when explicit credentials are provided.

  • ✗

    The S3 bucket policy denies access to the IAM role associated with the instance profile.

    Why it's wrong here

    A bucket policy could deny access, but the application is using environment variable credentials, not the instance profile role. The bucket policy would evaluate the principal from the explicit credentials, so if it denies that principal, access is denied. However, the most likely cause is that the explicit credentials themselves are invalid or lack permissions, not a bucket policy denial.

  • ✗

    The EC2 instance metadata service is disabled, preventing the SDK from retrieving temporary credentials.

    Why it's wrong here

    If the instance metadata service were disabled, the SDK would not be able to retrieve credentials from the instance profile, but the application is explicitly setting credentials via environment variables, so the metadata service is not being used. The access denied is due to the explicit credentials, not the metadata service.

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

Courseiva writes every SCS-C02 question from scratch — 1,205 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 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 SCS-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 SCS-C02 exam.