How to Transfer data between Amazon EC2 and S3

Table of contents
Reading Time: 3 minutes

Hello Readers! In this blog, we will see how to transfer data between amazon ec2 and s3 buckets. Basically what we will do is we will upload files to s3 buckets by using the ec2 instance. EC2 is a computing service for AWS and S3 is an object storage service offered by AWS. 

Let’s do it!

Step1: Create an EC2 instance by using which you want to transfer files. Follow the following blog for reference:

Steps to launch an ec2 instance

Here is my ec2 instance which I will use further:

AWS ec2

Step2: Create an IAM role by which we will be providing full access for s3 buckets to our ec2 instance.


Select Ec2 as the use case:


Select AmazonS3FullAccess policy:


Click Next. Fill in the role details.

role detail

My role is created now. We will use this in our ec2 instance.

create role

Step3: Attach this IAM role to the ec2 instance.

aws role

Step4: Create an S3 bucket in which you want to transfer data using EC2. This is my bucket which I will use:

Step5: Connect to that instance. So, these are the files that I want to transfer. 


Use the following command for sending it to the s3 bucket:

$ aws s3 cp <file_name> s3://<bucket_name>

s3 bucket

My file is successfully uploaded to the s3 bucket by the ec2 instance. We can see those files in my s3 bucket also:

s3 bucket

This is how we can transfer data between the ec2 instance and the s3 bucket.

We are all done now!!


Thank you for sticking to the end. In this blog, we have learned how we can transfer data between amazon ec2 and s3. This is really very quick and simple. If you like this blog, please share my blog and show your appreciation by giving thumbs-ups, and don’t forget to give me suggestions on how I can improve my future blogs that can suit your needs.


Written by 

Naincy Kumari is a DevOps Consultant at Knoldus Inc. She is always ready to learn new technologies and tools. She loves painting and dancing.