Back

Couldn't get S3 adaptor to work

  • 0
  • Storage
mav8rick
20 Jul, 2023, 19:59

Hi, due to the security considerations of using access key and secret, I have created a "special user" with no powers beyond that over the designated S3 bucket (s3: ). However, I couldn't even get the initial console's uploading of a single small file to work - just stayed stuck at "UPLOADING FILES (1)".
Initially, I thought it was due to SSL but even after forcing the browser to accept the self-signed cert, the problem remains. I looked around the logs of the containers and found that there is an "access denied" error (see screenshot) around line 808 of /usr/src/code/vendor/utopia-php/Storage/Device/S3.php What kind of rights (policy) should I have applied on the S3 bucket? I thought s3:
on that bucket would solve all problems but I guess it didn't. Would appreciate any pointers you can give.

TL;DR
User is having trouble getting the S3 adaptor to work for uploading files. They have tried giving the user full rights to the bucket, but it didn't work. Someone suggests adding `/*` to the policy to apply it to everything in the bucket. Other suggestions include checking the resource in the policy, using a different access key and secret, and checking for misconfigured environment variables. User also mentions that they created a user with restricted rights to the bucket and are using their access key and secret. There is speculation about whether the issue is related to Appwrite or the AWS policy. User asks for advice on what rights/policies to apply
D5
20 Jul, 2023, 20:22

You should use a key and secret

D5
20 Jul, 2023, 20:24

There should not be any problems regarding security unless Appwrite has some exploit or security issue (currently not known any issue regarding buckets connection with adapters)

mav8rick
21 Jul, 2023, 03:05

I am using a working access key and secret. Am wondering why I am seeing that AccessDenied error unless it’s some “action” that I have to explicitly allow in a policy

mav8rick
21 Jul, 2023, 03:08

No “problem” with security - just that I created a user with full rights to the bucket and then use that user’s access key and secret in the .env

Drake
21 Jul, 2023, 04:11

usually, the problem is some misconfigured env var

mav8rick
21 Jul, 2023, 07:46
mav8rick
21 Jul, 2023, 07:47

I am 100% sure it's a rights issue because when I replaced that "restricted" user with another user that has "power user" rights in the AWS account, the upload went through. I don't have time to check the AWS logs for now but I will. Hopefully someone can enlighten me in the meantime. The screenshot I attached is for the "restricted" user but I gave this user all the appropriate rights for the S3 bucket that I can think of.

mav8rick
21 Jul, 2023, 08:55
Drake
21 Jul, 2023, 14:43

Do you have a /* for that bucket?

mav8rick
21 Jul, 2023, 17:34

I don't quite understand that question... how would that affect the access control? I have a user A (policy as shown) who has full rights to the S3 bucket and then I have user B with no explicit policy imposed - B is just a "Power User" (as defined in AWS pre-canned set of policies). I put in B's access key and secret => no problem, I put in A's and I got hit with AccessDenied. Why?

mav8rick
21 Jul, 2023, 17:35

I mean - you guys can try this out - just create a vanilla user via IAM, apply this inline policy and generate the access key and secret from it and put it into .env and see if you get the same problem.

Drake
21 Jul, 2023, 19:19

The resource on line 10. It's redacted so I can't tell what you have at the end after the bucket name

mav8rick
25 Jul, 2023, 09:35

The resource points to a specific bucket, there is nothing after the specific ID for the bucket

Drake
25 Jul, 2023, 16:27

perhaps you should try adding /* or maybe another statement that grants to /*?

mav8rick
30 Jul, 2023, 16:20

That's the point... if Appwrite only needs permission to that 1 particular bucket, what other rights do I need to grant besides given full rights to that 1 single bucket? I have added "ListAllMyBuckets" and "GetBucketLocation" but what else? Note that I have given FULL rights to that 1 bucket that Appwrite is using. It's all a matter of ensuring I'm not giving it more rights that needed e.g. why should I grant it full rights to ALL buckets in the account?

Drake
30 Jul, 2023, 16:21

Did you try what I suggested?

mav8rick
30 Jul, 2023, 16:23

I got it working by giving it "Power User" which gives the user the ability to spin up EC2s, setup VPCs etc. but that's "too much" for a user that's only supposed to be using that 1 single bucket

Drake
30 Jul, 2023, 16:23

I don't know much about AWS policies but what I saw was you need the /* to apply the policy to everything in the bucket.

mav8rick
30 Jul, 2023, 16:23

I will try it tomorrow - thanks!

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more