Mount S3 (s3fs) on EC2 with dynamic files - Permanent public permission

Using S3FS and FUSE to mount the S3 bucket to an AWS EC2 instance, I ran into a problem when my S3 files are updated but the new files do not accept the proper resolution.

The ACL rights that were set by the new files were "---------" instead of "rw-rr--". I made sure that the bucket is installed correctly:

sudo /usr/bin/s3fs -o allow_other -o default_acl="public-read" [bucketname] [mountpoint] 

and creating an automaton in / etc / fstab:

 s3fs#[bucketname] [mountpoint] fuse defaults,noatime,allow_other,uid=1000,gid=1000,use_cache=/tmp,default_acl=public-read 0 0 

and the password file in / etc / passwd -s3fs with permission.

My setup is Ubuntu 13.04, PHP5, AWS SDK.

After 2 days of the experiment, I found a solution (for php) in the answer below.

+2
amazon-s3 amazon-web-services amazon-ec2 s3fs fuse
source share
2 answers

In my php script that PUT files in S3 using the AWK SDK for PHP, I had to add metadata, as shown below, which did the trick:

 $response = $s3->create_object('bucketname', 'mountpoint/'.$filename, array( 'body' => $json_data, 'contentType' => 'application/json', 'acl' => AmazonS3::ACL_PUBLIC, 'meta' => array( 'mode' => '33188', // x-amz-meta-mode ) )); 

The “33188” mode determined the permissions “rw-rr--” instead of “---------" in the S3 bucket (but it was reflected only in the folder installed in EC2), which was later inherited by the installed EC2 disk.

Hope this helps someone. Let me know!

+6
source share

s3fs # [bucketname] [mountpoint] fuse defaults, noatime, allow_other, uid = 222, gid = 48, use_cache = / tmp, default_acl = public-read 0 0

For me, this line works without installing x-amz-meta-mode! take care: uid = 222 for my ec2-user server and gid = 48 for my apache server group.

All php scripts are executed with the apache group. That is why I think you need to put gid at 48.

see also Change user permissions on buckets installed by s3fs

0
source share

All Articles