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?
Answer choices
Why each option matters
Good practice is not just finding the correct option. The wrong answers often show the exact trap the exam wants you to fall into.
Distractor review
Store the AWS access key ID and secret access key in a configuration file on the instance's local disk.
This option directly violates the security requirement by storing long-term credentials permanently on the instance. If the instance is compromised, the static credentials can be stolen and used by an attacker.
Best answer
Create an IAM role with the required S3 read permissions. Attach the role to the EC2 instance profile.
This is the correct and most secure method. The EC2 instance assumes the IAM role, obtaining temporary, automatically-rotated credentials. No long-term secrets are stored on the instance, complying with the security policy.
Distractor review
Write a resource-based policy on the S3 bucket that allows access based on the private IP address of the EC2 instance.
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.
Distractor review
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.
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.
Common exam trap
Common exam trap: usable hosts are not the same as total addresses
Subnetting questions often tempt you into counting all addresses. In normal IPv4 subnets, the network and broadcast addresses are not usable host addresses.
Technical deep dive
How to think about this question
Subnetting questions test whether you can identify the network, broadcast address, usable range, mask and correct subnet. Slow down enough to calculate the block size correctly.
KKey Concepts to Remember
- CIDR notation defines the prefix length.
- Block size helps identify subnet boundaries.
- Network and broadcast addresses are not usable hosts in normal IPv4 subnets.
- The required host count determines the smallest suitable subnet.
TExam Day Tips
- Write the block size before choosing the subnet.
- Check whether the question asks for hosts, subnets or a specific address range.
- Do not confuse /24, /25, /26 and /27 host counts.
Related practice questions
Related CLF-C02 practice-question pages
Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.
AWS shared responsibility model practice questions
Practise CLF-C02 questions linked to AWS shared responsibility model.
AWS Cloud Practitioner cloud concepts practice questions
Practise CLF-C02 questions linked to AWS Cloud Practitioner cloud concepts.
AWS IAM practice questions
Practise CLF-C02 questions linked to AWS IAM.
AWS pricing practice questions
Practise CLF-C02 questions linked to AWS pricing.
AWS support plans practice questions
Practise CLF-C02 questions linked to AWS support plans.
AWS S3 practice questions
Practise CLF-C02 questions linked to AWS S3.
AWS EC2 practice questions
Practise CLF-C02 questions linked to AWS EC2.
More questions from this exam
Keep practising from the same exam bank, or move into a focused topic page if this question exposed a weak area.
Question 1
A developer needs to launch a test server for a new application prototype. The developer logs into the AWS Management Console, selects an Amazon EC2 instance type, configures the security group, and starts the instance. The instance is running within two minutes, and the developer did not need to submit a formal request to the company's IT procurement team or wait for approval from a cloud administrator. Which essential characteristic of cloud computing does this scenario best demonstrate?
Question 2
A solutions architect is planning a new web application on AWS. The workload will include 3 Amazon EC2 instances (t3.medium) running 24/7, an Application Load Balancer, and an Amazon RDS for MySQL db.t3.small database. The architect needs to estimate the monthly cost for the first year, considering different purchasing options (On-Demand, 1-year All Upfront Reserved Instance, and Compute Savings Plan). Which AWS tool should the architect use to create this estimate?
Question 3
A company's development team frequently needs temporary test environments. A developer can log into the AWS Management Console, select an Amazon EC2 instance type, configure storage, and launch the instance within minutes without any interaction with the IT infrastructure team. This capability is an example of which essential characteristic of cloud computing?
Question 4
A company's finance team needs to analyze AWS spending in detail. They require a report that includes hourly cost data for each AWS service, each individual resource (e.g., a specific EC2 instance), and any cost allocation tags applied. The team plans to export this data to an Amazon S3 bucket and then import it into a custom business intelligence (BI) analytics dashboard. Which AWS tool should the finance team use to generate this level of detailed cost data?
Question 5
A company uses AWS for its development environment. The finance team wants to set a monthly budget of $10,000. They want to receive an email notification when the actual costs reach 80% of the budget ($8,000) and again when costs exceed the budget. The team needs a managed AWS service that can automatically send these alerts without requiring custom code or third-party tools. Which AWS service should the team use?
Question 6
A company uses AWS Organizations to manage multiple accounts. The security team needs to enforce a policy that restricts SSH access (port 22) from the internet (0.0.0.0/0) in all VPCs across all accounts. The team wants to centrally define the allowed rules and automatically apply them to newly created VPCs and security groups, while also automatically remediating any existing non-compliant security groups. Which AWS service should the team use?
FAQ
Questions learners often ask
What does this CLF-C02 question test?
CIDR notation defines the prefix length.
What is the correct answer to this question?
The correct answer is: Create an IAM role with the required S3 read permissions. Attach the role to the EC2 instance profile. — The most secure AWS best practice for granting an EC2 instance access to AWS services (like S3) is to use an IAM role. The role is attached to the EC2 instance via an instance profile. The AWS SDK or CLI running on the instance automatically retrieves temporary credentials from the instance metadata service (IMDS). These credentials are rotated automatically and never stored persistently on the instance. This approach eliminates the need to manage long-term access keys on the instance, fully satisfying the security team's mandate.
What should I do if I get this CLF-C02 question wrong?
Then try more questions from the same exam bank and focus on understanding why the wrong options are tempting.
Discussion
Sign in to join the discussion.