There is 2 way to connect and mount S3 into your EC2. One is using user secret key and access and another is using the IAM role.
Here is the step by step to create IAM user access
1. Login to your AWS console and go to IAM section.
2. Click create a new group of users
3. create a project name
4. select Amazon S3 Full Access
5. Click Continue
6. Create a users for this if you do not have a user or add existing users. this is if you have another users to manage your AWS and limited access. If you are admin itself, just go to account and use the security key and secret key
7. confirm the details and click Continue
8. drop down and save your access key ID and secret access key
Here is the step by step for creating IAM roles
1. Click on Roles and create new role
2. Create a role name
3. Select Amazon EC2
4. Select Amazon S3 Full Access
5. Click Continue
6. Confirm everything and create role
Now you need to create an EC2 instance, but do take note, during creating, you should be stop at this pages, and you need to select the IAM role to the one you created just now
After done create an instance, ssh into it and we start to install package needed
this is package needed for later use
# yum install kernel-devel libxml2-devel curl-devel gcc gcc-c++ pkgconfig openssl-devel subversion git -y
this is the package we will be using to install and mount
# yum install automake fuse fuse-devel -y
download down the latest s3fs-fuse package
# git clone https://github.com/s3fs-fuse/s3fs-fuse.git
configure, make, and make install
# cd s3fs-fuse
# ./configure --prefix=/usr
# make
# make install
Now we create a folder for mounting
# mkdir /data
If you are using IAM role, mount it using this command
# /usr/bin/s3fs <bucket name> /data -o rw,allow_other,uid=0,gid=0,default_acl=public-read,iam_role=<IAM role name>
If you are using user secretkey and access
# echo "<Access Key ID>:<Secret Access Key>" | tee -a /etc/passwd-s3fs # chmod 640 /etc/passwd-s3fs
then mount it using this command
# /usr/bin/s3fs <Bucket Name> /data -o rw,allow_other,uid=<UID>,gid=<GID>,default_acl=public-read
After success, you can use df to show out the partition to confirm it
Thanks for providing this informative information you may also refer.
ReplyDeletehttp://www.s4techno.com/blog/2015/12/21/protect-instances-from-termination-by-auto-scaling/
Thanks for providing your information and Keep update and share AWS Online Training
ReplyDelete