Mount S3 to an EC2 Instance: Difference between revisions
From Cramsession
Jump to navigationJump to search
✍️ Verified Author: Mflavell • Click to view professional profile & credentials
No edit summary |
|||
| Line 49: | Line 49: | ||
Add the lines | Add the lines | ||
s3fs#''bucket_name | s3fs#''bucket_name'' /mnt/s3-bucket fuse _netdev,iam_role=S3AccessForEC2,allow_other 0 0 | ||
= References = | = References = | ||
https://surajblog.medium.com/mount-aws-s3-bucket-on-amazon-ec2-9f18b48d4f04 | https://surajblog.medium.com/mount-aws-s3-bucket-on-amazon-ec2-9f18b48d4f04 | ||
Latest revision as of 23:40, 9 March 2025
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
Test it
sudo s3fs 'bucket_name' /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-aws_region.amazonaws.com
Debugging
Add the lines
-o dbglevel=info -f -o curldbg
Making it permanent
Open FSTAB
sudo nano /etc/fstab
Add the lines
s3fs#bucket_name /mnt/s3-bucket fuse _netdev,iam_role=S3AccessForEC2,allow_other 0 0
References
https://surajblog.medium.com/mount-aws-s3-bucket-on-amazon-ec2-9f18b48d4f04