Courseiva
Security and CompliancemediumMultiple ChoiceObjective-mapped

CLF-C02 Security and Compliance Practice Question

A company runs a data analytics application on an Amazon EC2 instance. The application needs to read CSV files from an Amazon S3 bucket to process them. The security team requires that no long-term AWS credentials (access key ID and secret access key) be stored on the instance. The instance is already launched in a private subnet within a VPC. Which solution meets the security requirement and provides the necessary access?

⚠ Common exam trap

Many candidates think storing credentials in a secure service like Systems Manager Parameter Store (Option D) is sufficient, but it still involves long-term IAM user keys, whereas the IAM role approach provides fully temporary credentials that are automatically rotated and never stored on the instance.

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 the required S3 read permissions. Attach the role to the EC2 instance profile.

It uses an IAM role attached to an EC2 instance profile, which allows the application to obtain temporary AWS credentials via the instance metadata service (IMDS). This eliminates the need to store long-term access keys on the instance, satisfying the security requirement while granting the necessary S3 read permissions.

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 ID and secret access key in a configuration file on the instance's local disk.

    Why it's wrong here

    Embedding an access key ID and secret access key in a configuration file on the instance stores permanent static credentials that do not expire and would require manual rotation to maintain security. If the instance is compromised, the attacker can copy those keys and use them from anywhere, directly violating the security policy's requirement to avoid storing long-term credentials on the instance. Even if the configuration file is encrypted on disk, the application must decrypt it into memory at runtime, creating an attack surface that the IAM role approach eliminates.

    When this WOULD be correct

    If the question explicitly allowed storing long-term credentials and required a simple, direct method to provide access without setting up IAM roles or instance profiles, storing credentials in a configuration file would be a straightforward solution.

  • Create an IAM role with the required S3 read permissions. Attach the role to the EC2 instance profile.

    Why this is correct

    An IAM role is the recommended identity for an EC2 application because the instance assumes the role through its instance profile, and the AWS SDK retrieves temporary credentials from the EC2 instance metadata service (IMDS). These credentials are issued by AWS STS, are valid for a limited session, and are automatically rotated before expiry, so the application never handles a long-lived secret. Attaching the role to the instance profile and allowing the application to use the SDK's default credential chain gives the instance exactly the S3 read permissions scoped by the role's policy.

  • Write a resource-based policy on the S3 bucket that allows access based on the private IP address of the EC2 instance.

    Why it's wrong here

    S3 bucket policies can use the aws:SourceIp condition, but that condition expects public IP addresses, not private IPs. Since the instance is in a private subnet without a public IP, this policy would not grant access. Additionally, IP-based authorization alone is not a secure replacement for IAM credentials.

    When this WOULD be correct

    If the question required granting cross-account access to an S3 bucket without using IAM roles, and the EC2 instance had a static public IP (Elastic IP) in a VPC with a VPC endpoint, a bucket policy with aws:SourceIp condition could be used, but only for public IPs, not private.

  • Create a new IAM user with the required permissions. Store the IAM user's access key and secret key in AWS Systems Manager Parameter Store, and configure the application to retrieve them at runtime.

    Why it's wrong here

    Although this method separates credentials from the code, it still uses long-term IAM user access keys. These are static secrets that can be leaked if Parameter Store access is compromised. The IAM role approach is more secure because it uses temporary credentials that are automatically rotated.

    When this WOULD be correct

    If the question required using temporary credentials but the instance cannot use an IAM role (e.g., the instance is not in EC2 or is in an on-premises environment), then storing access keys in Parameter Store and retrieving them at runtime would be a valid solution to avoid hardcoding credentials.

Option-by-option analysis

Why each answer is right or wrong

Understanding why wrong answers are wrong — and when they would be correct — is what separates a 750 score from a 900. The CLF-C02 exam frequently reuses these exact scenarios with slightly different constraints.

Create an IAM role with the required S3 read permissions. Attach the role to the EC2 instance profile.Correct answer

Why this is correct

An IAM role is the recommended identity for an EC2 application because the instance assumes the role through its instance profile, and the AWS SDK retrieves temporary credentials from the EC2 instance metadata service (IMDS). These credentials are issued by AWS STS, are valid for a limited session, and are automatically rotated before expiry, so the application never handles a long-lived secret. Attaching the role to the instance profile and allowing the application to use the SDK's default credential chain gives the instance exactly the S3 read permissions scoped by the role's policy.

Store the AWS access key ID and secret access key in a configuration file on the instance's local disk.Wrong answer — click to see why

Why this is wrong here

Storing long-term AWS credentials (access key ID and secret access key) on the instance violates the security requirement that no long-term credentials be stored on the instance.

★ When this WOULD be the correct answer

If the question explicitly allowed storing long-term credentials and required a simple, direct method to provide access without setting up IAM roles or instance profiles, storing credentials in a configuration file would be a straightforward solution.

Why candidates choose this

Candidates may be familiar with configuring applications using static credentials and overlook the security requirement against storing long-term credentials on the instance.

Write a resource-based policy on the S3 bucket that allows access based on the private IP address of the EC2 instance.Wrong answer — click to see why

Why this is wrong here

S3 bucket policies cannot grant access based on EC2 instance private IP addresses because private IPs are not a supported condition key for S3 actions; they are not reliably associated with the instance in a way that S3 can evaluate.

★ When this WOULD be the correct answer

If the question required granting cross-account access to an S3 bucket without using IAM roles, and the EC2 instance had a static public IP (Elastic IP) in a VPC with a VPC endpoint, a bucket policy with aws:SourceIp condition could be used, but only for public IPs, not private.

Why candidates choose this

Candidates may think that IP-based access control is a simple way to restrict access without managing credentials, and they might overlook that S3 bucket policies support IP address conditions only for public IPs, not private IPs within a VPC.

Create a new IAM user with the required permissions. Store the IAM user's access key and secret key in AWS Systems Manager Parameter Store, and configure the application to retrieve them at runtime.Wrong answer — click to see why

Why this is wrong here

The question explicitly requires that no long-term AWS credentials be stored on the instance. While Parameter Store avoids storing keys on the disk, the application still retrieves and uses long-term IAM user access keys at runtime, violating the security requirement.

★ When this WOULD be the correct answer

If the question required using temporary credentials but the instance cannot use an IAM role (e.g., the instance is not in EC2 or is in an on-premises environment), then storing access keys in Parameter Store and retrieving them at runtime would be a valid solution to avoid hardcoding credentials.

Why candidates choose this

Candidates may think that using Parameter Store eliminates the need to store credentials on the instance's local disk, but they overlook that the IAM user access keys are still long-term credentials that are retrieved and used by the application, which does not meet the 'no long-term credentials' requirement.

Analysis generated from the official CLF-C02blueprint and verified against question context. The “when correct” sections are what AI assistants cite when candidates ask “what’s the difference between these options?”

Visual reference

192.168.1.0 /24 256 addresses (254 usable) 192.168.1.0 /25 Subnet A 128 addr (126 usable) 192.168.1.128 /25 Subnet B 128 addr (126 usable) Borrowing 1 bit from host portion creates 2 subnets (/25)

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 CLF-C02 question from scratch — 988 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 CLF-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 CLF-C02 exam.