Skip to main content
  1. Home
  2. >
  3. AWS
  4. >
  5. SAA-C03
  6. >
  7. AWS SAA-C03 Exam Scenarios
  8. >
  9. EC2 to S3 Access—Role vs Keys | SAA-C03

EC2 to S3 Access—Role vs Keys | SAA-C03

Jeff Taakey
Author
Jeff Taakey
21+ Year Enterprise Architect | Multi-Cloud Architect & Strategist.

While preparing for the AWS SAA-C03, many candidates get confused by EC2-to-S3 connectivity options. In the real world, this is fundamentally a decision about Security vs. Operational Overhead. Let’s drill into a simulated scenario.

The Scenario
#

TechStart Labs is deploying a new document management platform that runs on two Amazon EC2 instances in a private subnet. The application needs to store and retrieve PDF reports from an Amazon S3 bucket. The security team has mandated that all AWS service access must follow the principle of least privilege and avoid embedding long-term credentials in application code.

The Solutions Architect must configure secure access for the EC2 instances to interact with the S3 bucket.

Key Requirements
#

Enable EC2 instances to securely read and write objects to the S3 bucket while adhering to AWS security best practices and minimizing operational complexity.

The Options
#

  • A) Create an IAM role with appropriate S3 permissions and attach it to the EC2 instances.
  • B) Generate IAM user access keys and store them in the application configuration file on each EC2 instance.
  • C) Deploy a NAT Gateway in the public subnet and create a VPC endpoint for S3 to route traffic.
  • D) Configure S3 bucket policies to allow access from the VPC CIDR range and enable public access for the application.

Correct Answer
#

Option A.

The Architect’s Analysis
#

Correct Answer
#

Option A: Create an IAM role with appropriate S3 permissions and attach it to the EC2 instances.

Step-by-Step Winning Logic
#

This solution represents the AWS best practice for EC2-to-S3 communication because:

  1. Security Excellence: IAM roles provide temporary credentials that are automatically rotated every 5-6 hours. No static keys exist in your codebase or configuration files.
  2. Zero Additional Cost: No charges for IAM role usage, API calls, or credential rotation.
  3. Operational Simplicity: EC2 instances automatically obtain credentials via the instance metadata service (IMDS). No manual key distribution or rotation required.
  4. Least Privilege Enforcement: You can scope the role policy to specific S3 actions (s3:GetObject, s3:PutObject) and specific bucket ARNs.

The Traps (Distractor Analysis)
#

  • Why not Option B (IAM User Access Keys)?

    • Security Risk: Hardcoded credentials in configuration files violate AWS security best practices and create audit compliance issues.
    • Operational Overhead: Requires manual key rotation every 90 days (AWS recommended practice), increasing operational toil.
    • Blast Radius: If an EC2 instance is compromised, the attacker gains long-term credentials that remain valid until manually revoked.
  • Why not Option C (NAT Gateway + VPC Endpoint)?

    • Conceptual Confusion: This option conflates network routing with authentication/authorization. While a VPC endpoint for S3 is a good practice (reduces NAT Gateway data transfer costs), it doesn’t solve the IAM authentication problem.
    • Unnecessary Cost: NAT Gateway costs ~$0.045/hour ($32.40/month) + $0.045/GB data processed when a free VPC endpoint suffices.
  • Why not Option D (Bucket Policy with VPC CIDR + Public Access)?

    • Security Violation: Enabling public access on an S3 bucket is a major security anti-pattern, especially for enterprise document storage.
    • Insufficient Access Control: VPC CIDR-based bucket policies don’t authenticate individual EC2 instances. Any compromised instance in the VPC gains access.
    • Compliance Failure: Most regulatory frameworks (SOC 2, HIPAA, GDPR) prohibit public S3 buckets for sensitive data.

The Architect Blueprint
#

graph EC2_1[EC2 Instance 1<br/>Private Subnet] -->|Assumes Role via IMDS| IAM_Role[IAM Role<br/>S3ReadWritePolicy] EC2_2[EC2 Instance 2<br/>Private Subnet] -->|Assumes Role via IMDS| IAM_Role IAM_Role -->|Temporary Credentials| S3[S3 Bucket<br/>company-documents] style IAM_Role fill:#FF9900,stroke:#232F3E,stroke-width:3px,color:#fff style S3 fill:#569A31,stroke:#232F3E,stroke-width:2px,color:#fff style EC2_1 fill:#FF9900,stroke:#232F3E,stroke-width:2px,color:#fff style EC2_2 fill:#FF9900,stroke:#232F3E,stroke-width:2px,color:#fff

Diagram Note: EC2 instances automatically retrieve temporary credentials from the instance metadata service (IMDS v2 recommended) and use them to authenticate with S3 via the IAM role’s permissions policy.

The Decision Matrix
#

Option Est. Complexity Est. Monthly Cost Pros Cons
A: IAM Role Low (5 min setup) $0 ✅ AWS best practice
✅ Automatic credential rotation
✅ No operational overhead
✅ Audit-friendly
❌ Requires basic IAM knowledge
B: Access Keys Medium (requires secrets mgmt) $0-$500+ (if using Secrets Manager/Vault) ✅ Simple to understand ❌ Security risk
❌ Manual rotation required
❌ Fails compliance audits
C: NAT + VPC Endpoint High (network config) $32.40+ (NAT Gateway hourly + data) ✅ Reduces data transfer costs (if using endpoint) ❌ Doesn’t solve authentication
❌ Overengineered for this use case
D: Public Bucket Low $0 (storage + requests only) ✅ Fast to configure ❌ Severe security risk
❌ Violates least privilege
❌ Regulatory non-compliance

Real-World Practitioner Insight
#

Exam Rule
#

For the AWS SAA-C03 exam, always choose IAM roles when you see scenarios involving:

  • EC2 instances accessing AWS services (S3, DynamoDB, SQS, etc.)
  • Keywords like “secure,” “best practice,” or “least privilege”
  • Avoiding hardcoded credentials

Real World
#

In production environments, we would also:

  1. Enable VPC Endpoint for S3 (Gateway type, $0 cost) to keep traffic within the AWS network and reduce NAT Gateway costs if instances are in private subnets.
  2. Implement S3 Bucket Policies as a secondary layer of defense, restricting access to specific IAM role ARNs (defense in depth).
  3. Use IMDSv2 (Instance Metadata Service Version 2) to prevent SSRF attacks that could steal temporary credentials.
  4. Enable AWS CloudTrail to audit all S3 API calls made by the IAM role for compliance and forensic purposes.
  5. Tag IAM roles and S3 buckets for cost allocation and governance (e.g., Environment: Production, Owner: DevOps).

Cost Optimization Insight:
If your application generates heavy S3 traffic (>1TB/month), the VPC endpoint alone can save ~$45/TB compared to routing through a NAT Gateway ($0.045/GB). For a typical document management system with 500GB/month traffic, that’s $22.50/month saved — a 70% reduction in data transfer costs.

Accelerate Your Cloud Certification.

Stop memorizing exam dumps. Join our waitlist for logic-driven blueprints tailored to your specific certification path.