This project demonstrates a secure method for enabling an EC2 instance to upload files to an S3 bucket using IAM Roles, without storing any access keys or credentials.
The solution follows AWS security best practices by using temporary credentials and applying the principle of least privilege.
- AWS EC2
- AWS S3
- AWS IAM (Roles & Policies)
- AWS CLI
- An IAM Role is created with the required S3 permissions.
- The role is attached to an EC2 instance.
- EC2 automatically receives temporary credentials from AWS.
- A file is created inside the EC2 instance.
- AWS CLI is used to upload the file to the S3 bucket.
- The file is securely stored in the S3 bucket.
- Created an S3 bucket.
- Created an IAM Policy with the required S3 permissions.
- Created an IAM Role and attached the policy.
- Attached the IAM Role to the EC2 instance.
- Connected to the EC2 instance using SSH.
- Created a test file.
- Uploaded the file to the S3 bucket using AWS CLI.
- Verified that the file was uploaded successfully.
- No access keys or passwords stored on the EC2 instance.
- IAM Role used instead of IAM User credentials.
- Temporary credentials automatically managed by AWS.
- Only the required permissions are granted (least privilege).
This architecture is commonly used in production environments where applications running on EC2 need to upload logs, backups, reports, images, or other files to S3 without exposing AWS credentials.



