Step 1) Click on Services >> Write IAM and enter
Step 2) Click on Users >> Click on add user
Step 3) Write user name >> tick on "Programmatic access" >> click on next
Step 4) Click on "Attach existing policies directly" >> write S3 >> tick on "AmazonS3FullAccess" >> click on next
Provide Limited Access to the bucket so that you will be prevent from the accidental deletion and being hacked.
Below is S3-Custom-Inline-Policy allow only Download/Upload the object in the bucket.
Note : This user only can Put/Get the object from the source code and see the object via console.
Step 5) Write the tag >> click on next
Step 6) cilck on create user
Step 7) Download .csv file and click on close
.csv file have "Access key ID" and "Secret access key"
Login into Ubuntu terminal and install below following service
$ sudo apt-get install awscli
$ sudo apt-get install python-pip
Step 8) fill the details by below fllowing commands.
Note:- Access key and Secret access key will be copy from the .csv file.
$ aws configure
Step 9) Create New Bucket by below command.
$ aws s3 mb s3://mynews3awsclibucket/
Step 10) Create a test directory and create test file
$ mkdir test
$ touch test/test.txt
Step 11) Sync the local system folder from aws S3 bucket.
$ aws s3 sync "/home/ubuntu/test/" s3://mynews3awsclibucket/
Step 12) Now check your S3 bucket in aws
Click on services >> write s3 >> click on s3
Integration with cron
*/1 * * * * aws s3 sync "/home/ubuntu/test/" s3://mynews3awsclibucket/
Remove file older than 10 days
0 9 * * * /usr/bin/find /home/ubuntu/test/ -name "*.gz" -type f -mtime +10 -exec rm -f {} \;
- Create IAM Role and Attach S3 access policy.
- Attach IAM Role to EC2
$ aws s3 cp s3://ec22access/abc.txt s3://mynews3awsclibucket123/abc.txt
4.1) upload local system folder to S3 bucket.
No comments:
Post a Comment
testing