Amazon AWS S3 bucket permissions - amazon-web-services

I am trying to access an S3 bucket that I don't own, but have been granted access to through access policy. The access policy says I can access with getObject, listObject anything from /* . I am guessing that allows me to access everything within the bucket. However, what is happening is that I am able to only access few files while not able to access other.
And I suspect these files are new files in the bucket that did not exist at the time of the acl being granted. Something is writing into that bucket with default acl. Should that be the cause of acls not taking effect and the access denied?

Related

Limiting S3 bucket access to users within one account

I have an IAM user that has full S3 access (i.e. can perform any S3 actions on any S3 resource within the AWS account). This user has created a bucket and put some files in it. The bucket has a policy which just contains an Allow rule that grants access to a different IAM user, in the same AWS account. Public access is turned off for the bucket.
Should the first user be able to access objects in this bucket? If so, is that because they created the bucket, or because they're in the account that owns the bucket? Is it possible to limit access to a bucket for users within the same AWS account?
S3 is one of the few services with resource policies, in this case they are called bucket policies.
A user in the same account has access to a (S3) resource if
nothing explicitly denies the access AND
either the bucket policy grants access OR the user / entity has a policy attached that grants access
If you wanted to restrict a bucket to a single user / entity you would
need to write a bucket policy that specifies that using a Deny statement for every user except the target one AND
either add a statement to the bucket policy or a policy attached to the user / entity granting access to the bucket.
The standard doc for understanding policy evaluation logic is this. There are other, more complicated ways to achieve your goal using e.g. permission boundaries and SCPs but they are probably overkill in your situation.

AWS S3 read access to IAM user from external IP

I want to allow a specific IAM user (and no one else) to read files from a specific S3 bucket. I want to allow this IAM user to read the files from any external IP address. I have already created this IAM user, and attached a custom policy to this user allowing s3:GetObject operations on the one bucket.
I have also configured my S3 bucket to "Block all public access." My reasoning is that I don't want to allow access from any other user/stranger besides the designated IAM user.
I attempted to perform the read using the S3 SDK and the IAM user's API keys. And I'm getting the following error: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied
I suspect that this is happening because of my "block all public access" bucket config. I don't quite understand what AWS is referring to when they say public. Are they referring to access from random/uncredentialed users? Or are they referring to access from public IP addresses? For my use case, should I enable or disable the following configs?
Block public access to buckets and objects granted through new access control lists (ACLs)
Block public access to buckets and objects granted through any access control lists (ACLs)
Block public access to buckets and objects granted through new public bucket or access point policies
Block public and cross-account access to buckets and objects through any public bucket or access point policies
Update: Turns out I made an unrelated error in my permissions policy. I had granted the IAM user permissions to access arn:aws:s3:::my-bucket instead of arn:aws:s3:::my-bucket/*.
After fixing this, I'm able to use the IAM user to read from the s3 bucket, from an external IP, with block all public access still enabled. I can now confirm that this option does not block access from external IPs.
Thank you Mark B!

Insufficient permissions to list objects for bucket "XXXX" while deleting AWS S3 bucket

I got accidentally locked out of the AWS S3 bucket by not meeting certain conditions. I accidentally set bucket policies that explicitly deny access to any requests outside the allowed IP addresses. Now I am not able to either list objects, view the permissions, or anything inside the bucket and completely locked out of it.
How can I regain access to the bucket?
Here are some of the error screenshots:
Insufficient Permissions to list oBjects for a bucket while trying to delete the bucket
Objects Page
Permission Page
You can do this as a root user as explained in the following AWS docs:
I accidentally denied everyone access to my Amazon S3 bucket. How do I regain access?

S3 Bucket without ACL - No permission

I found an issue with a S3 bucket.
The bucket don't have any ACL associated, and the user that create the bucket was deleted.
How it's possible add some ACL in the bucket to get the control back?
For any command using AWS CLI, the result are the same always: An error occurred (AccessDenied) when calling the operation: Access Denied
Also in AWS console the access is denied.
First things first , AccessDenied error in AWS indicates that your AWS user does not have access to S3 service , Get S3 permission to your IAM user account , if in case you had access to AWS S3 service.
The thing is since you are using cli make sure AWS client KEY and secret are still correctly in local.
Now the interesting use case :
You have access to S3 service but cannot access the bucket since the bucket had some policies set
In this case if user who set the policies left and no user was able to access this bucket, the best way is to ask AWS root account holder to change the bucket permissions
An IAM user with the managed policy named AdministratorAccess should be able to access all S3 buckets within the same AWS account. Unless you have applied some unusual S3 bucket policy or ACL, in which case you might need to log in as the account's root user and modify that bucket policy or ACL.
See Why am I getting an "Access Denied" error from the S3 when I try to modify a bucket policy?
I just posted this on a related thread...
https://stackoverflow.com/a/73977525/999943
https://aws.amazon.com/premiumsupport/knowledge-center/s3-bucket-owner-full-control-acl/
Basically when putting objects from the non-bucket owner, you need to set the acl at the same time.
--acl bucket-owner-full-control

Access Denied error with Amazon S3

I'm getting an Access Denied error with Amazon S3 and can't figure out why.
My settings are as follows:
STATIC_URL = 'http://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME
What would cause an access denied error? I have verified that my keys are correct.
The URL you show above would resolve to a bucket within S3. In order to access that bucket successfully with such a URL, the permissions on the bucket would have to grant 'public-read' access to the bucket. In addition, each object or file within the bucket would have to grant 'public-read' access, as well.
Do you want the bucket and all content within the bucket to be readable by anyone? If so, make sure the permissions are set appropriately. Note, however, that granting 'public-read' to the bucket itself will allow anyone to list the contents of the bucket. That's usually unnecessary and probably should be avoided.
Also note that the keys (I assume you mean your AWS access key and secret key) only apply when you are accessing S3 via the API. If you simply access it with the URL via a browser, the credentials are not used in the request.