Setting Up EC2, IAM User, and S3 Bucket on AWS
Raees Qazi | DevOps Engineer | Learner | Mentor | Creator | Briller Technologies
In this guide, we will create an EC2 instance on AWS, set up an IAM user with full access to EC2 and S3, and access an S3 bucket using AWS CLI with access keys.
Project Overview
- EC2 Instance: A virtual machine on AWS.
- IAM User: A user with permissions to access EC2 and S3.
- S3 Bucket: A cloud storage service for storing files.
- AWS CLI: A command-line tool to interact with AWS services.
Workflow
- User → Local PC → EC2 Instance → IAM User → S3 Bucket
Step 1: Creating an EC2 Instance
- Log in to the AWS Management Console.
- Navigate to EC2 and click Launch Instance.
- Provide a name for the instance.
- Choose Ubuntu as the operating system.
- Select or create a key pair for SSH access.
- Allocate 8GB ROM (or as needed).
- Click Launch.
- Your EC2 instance is now running.
Step 2: Creating an IAM User
- Go to the IAM service.
- Click on Users and select Create User.
- Enter the username (e.g.,
aws-user). - Attach the following policies:
- AmazonS3FullAccess (Full access to S3)
- AmazonEC2FullAccess (Full access to EC2)
5. Click Create User.
6. The IAM user is now set up.
Generating Access Keys
- Click on the created IAM user.
- Navigate to Security Credentials.
- Under Access Keys, click Create Access Key.
- Select CLI as the use case.
- Acknowledge the warning and click Next.
- Click Create Access Key.
- Note the Access Key and Secret Key (needed for AWS CLI access).
Step 3: Creating an S3 Bucket
- Go to the S3 service.
- Click Create Bucket.
- Enter a unique bucket name.
- Keep default settings (ACL disabled, block public access enabled).
- Click Create Bucket.
- Your S3 bucket is now ready for use.
Step 4: Setting Up AWS CLI on EC2
- Connect to your EC2 instance using SSH:
ssh -i your-key.pem ubuntu@your-ec2-ip
2. Install AWS CLI:
sudo apt updatesudo apt install unzipcurl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"unzip awscliv2.zipsudo ./aws/install
3. Verify installation:
aws --version
4. Configure AWS CLI with IAM user credentials:
aws configure- Enter the Access Key.
- Enter the Secret Key.
- Skip Region (optional) or enter a region (e.g.,
us-west-2). - Skip Output Format (or enter
json).
5. Verify S3 access:
aws s3 ls

This command lists all available S3 buckets, confirming successful access.
Conclusion
We have successfully set up an EC2 instance, created an IAM user, configured an S3 bucket, and accessed it through AWS CLI. You can now upload and manage files in S3 directly from the command line.
If this guide was helpful, please share and subscribe for more DevOps tutorials!
Comments
Post a Comment