Mount S3 to an EC2 Instance
From Cramsession
✍️ Verified Author: Mflavell • Click to view professional profile & credentials
Create an IAM role
- Open IAM
- Select Roles
- Create Role
- Select AWS service / EC2
- Search AmazonS3FullAccess
- Select it
- Add any other rights you need
- Remember only one IAM role can be bound to EC2
- Click Next
- Give it a name
- Click Create Role
Bind the Role to a EC2 Instance
- Open EC2
- Select the Instance
- Select Actions > Security > Change Security Groups.
- Connect the IAM role
Install Software
- Connect to the instance
- Run the commands
sudo apt-get update -y sudo snap install aws-cli --classic sudo apt-get install s3fs -y
- Create a mount point
sudo mkdir /mnt/s3-bucket
- Mount the S3 bucket
sudo s3fs Flavell /mnt/s3-bucket -o iam_role=S3AccessForEC2 -o use_cache=/tmp -o allow_other -o uid=1001 -o mp_umask=002 -o multireq_max=5 -o use_path_request_style -o url=https://s3-Template:Aws region.amazonaws.com
References
https://surajblog.medium.com/mount-aws-s3-bucket-on-amazon-ec2-9f18b48d4f04