DEV Community

Shaakthi Ganapathi
Shaakthi Ganapathi

Posted on

AWS EC2 Instance with S3 Integration

Amazon Web Services (AWS) provides a robust platform for deploying and managing cloud infrastructure. In this blog, we’ll guide you through the steps to set up an EC2 instance, connect to it via SSH, assign an IAM role, and upload a file to an S3 bucket.

Step 1: Launching an EC2 Instance

1.Log in to AWS Management Console: Navigate to the EC2 service.

2.Choose Amazon Linux as the Amazon Machine Image (AMI): Select the free tier-eligible Amazon Linux AMI.

3.Select Instance Type: Choose t2.micro for free tier eligibility.

4.Create or Choose a Key Pair: Create a new key pair or select an existing one. Download the private key file (.pem).

5.Launch the Instance: Review your configuration and launch the instance.

Image description

Step 2: Configuring Security Groups

Edit Inbound Rules: Go to the instance's security group and add an inbound rule to allow SSH traffic (port 22) from your IP address.

Image description

Step 3: Setting Up puTTY

Download puTTY: Download and install puTTY along with puTTYgen from putty.org.

Convert .pem to .ppk: Use puTTYgen to convert your .pem file to a .ppk file.

Image description

Step 4: Connecting to the Instance

Open puTTY: Enter the public IP address of your EC2 instance in the "Host Name" field.

Upload Key: Navigate to the SSH > Auth section and upload your .ppk file.

Connect: Click "Open" and log in as ec2-user.

Image description

Image description

Image description

Step 5: Assigning an IAM Role to the Instance

1.Create an IAM Role:Navigate to the IAM service and create a role with Amazon S3 full access.
Attach the role to your EC2 instance.

2.Verify Role Assignment: Confirm that the instance has the appropriate permissions.

Image description

Image description

Step 6: Uploading a File to S3

Prepare a File: Create or copy a file in your EC2 instance.
Use AWS CLI: Use the following command to upload a file to your S3 bucket:

       aws s3 cp <file-path> s3://<bucket-name>/
Enter fullscreen mode Exit fullscreen mode

Image description

Step 7: Cleaning Up Resources

Terminate the Instance: Stop and terminate the EC2 instance to avoid unnecessary charges.

Delete the IAM Role: Remove the role from your instance and delete it if no longer needed.

Image description

Image description

Image description

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more