Mounting S3 bucket into an EC2 instance
One of our clients has hosted his application on AWS and it uses EC2 instances behind the load balancer. The application provides an interface where users are suppose to upload files. For saving the same on centralize location we use S3 bucket and mount the same on the EC2 instances. Following are the step which we follow to get the things working:
Prerequisite : First we execute the following command, which will install the required packages necessary to install S3fs command.
Debian:
sudo apt-get install make gcc g++ pkg-config libfuse-dev libcurl4-openssl-dev libxml2-dev
Amazon AMI:
yum remove fuse fuse*fuse-devel yum install gcc libstdc++-devel gcc-c++ curl-devel libxml2-devel openssl-devel mailcap fuse fuse-devel
Now we download the S3fs code, untar it and install it by using following command:
cd /opt wget tar xzvf s3fs-1.71.tar.gz cd s3fs-1.71/ ./configure make make install
vim /etc/passwd-s3fs
Now we will store our secret key and access key like following:
chmod 640 /etc/passwd-s3fs
sed -ie 's/#user_allow_other/user_allow_other/g' /etc/fuse.conf
mkdir /var/www/uploads
s3fs <bucketname> -o use_cache -o allow_other /var/www/uploads
How can access files stored in s3 mounted in ec2 folder?
Connection established, waiting for welcome message…
Response: 220 (vsFTPd 2.2.2)
Command: USER backup
Response: 530 Permission denied.
Error: Could not connect to server
Getting error after connecting to ftp. User default directory set as s3 bucket mounted folder.