How to mount AWS S3 bucket into AWS EC2 instance Step by Step
In this article i will go thru the steps required to mount an AWS S3 Bucket to an Linux EC2 instance.
I assume who will follow this article will already have an AWS account setup and knows already what an EC2 & S3 Bucket are.
A - For this you will need to install fuse and s2fs packages
Follow the steps bellow to do this (this was done using a Centos 6.+ Linux Box)
B - After you have installed s2fs & fuse you will need setup the AWS account access.
run the following commands as the root user.
C - Next you will need to create and user that will manage your S3 storage.
Follow this steps to see how to create a new user that will have S3 Storage administration privileges.
1 - Go to Identity and Access Management Service(IAM)
2 - Select the users tab.
3 - Choose to create a new user.
4 - Give the user a name, i will call it "s3_access", you can call it the way you want.
5 - When the user is created AWS will prompt you with the users credentials.
Very important : save them on your computer or "memorize" them.
They look something like this, where you have a column header and their respective values. We only will need the Access Key ID & Secret Access Key.
6 - Setup user policy rights.
the user was created but is "naked", meaning it has no rights.
you need to go to the "Policies" tab and look for the AmazonS3FullAccess Policy
Once selected you need to attach/"grant" the policy to user(in our case the s3_access user).
Select the s3_access user from the list of users and select the button "Attach Policy". Now our s3_access user has full control over our S3 storage resources.
D - Next you need to alter the file and put in your AWS S3 credentials
just copy and paste the command bellow after you edit the Access Key and the Secret Access Key with your own values from the S3_access user.
E - Create mount point
F - Mount the s3 bucket device on your mount point
Now you can use the S3 bucket as your own file system.
Note : - is important that if you want this to always be mounted when you machine reboot you need to put this entry in your /etc/fstab file
To test the edited /etc/fstab file unmount the s2fs device and run umount -a, this command should mount your device the same way the bootloader does.
nice the device was mounted and this way we validated that it will come up with the bootloader.