Tuesday, December 8, 2020

Sync Up EC2 instance With S3 bucket

 Description: Here I have explained how to sync EC2 instance with S3 bucket 

Create an IAM User:  First I am creating IAM user for authentication and authorization


  • Select the option "Attach existing policy" and search for "AdministratorAccess" and "AmazonEC2FullAccess" 
  • Review policy and click on Create User 
  • Download .csv file and save in the local path 

  • Create EC2 instance and log on to the machine once the instance is up
  • Run aws configure command to configure user details where it will ask AccessKey and SecretKey. It will ask some information from CSV file which download under Create IAM user as follow 


  • Now I am installing HTTP on server using below command
# yum install httpd



  • Create default.php file in /var/www/html 
Create S3 Bucket 
  • To create S3 Bucket open Amazon S3 console and choose "Create Bucket" 
  • In "Create a Bucket" type a bucket name in the Bucket Name field



  • Create an empty bucket and looks like as follow

Sync EC2 instance with S3 bucket 
  • To sync EC2 content to S3 bucket access  ssh console and run below command
# aws s3 sync /var/www/html/ s3://testsynch/datasync

Description of the above command

aws s3 sync                   -    To sync
/var/www/html/             -    Path where our actual php file is placed in EC2
s3://testsynch/datasync  -    Path where to Sync in S3 bucket



  • Now you can see default.php under S3 bucket 




1 comment: