3

If someone gives me an S3 url with a bucket and an object, but I don't know which account owns the bucket, how can I determine which credentials to present in order to gain access to the object, assuming I have access to hundreds of AWS accounts, but I just don't know which one to look in?

  • 1
    S3 object URLs does not have any piece of information that can be related to an account. You need at least S3 bucket ARN to get the owner account id. – theist Oct 2 '18 at 10:54
1

I would simply ask them what account it is ;)

Otherwise if you can’t tell from the bucket name you will have to list buckets from each account and see if your bucket is there.

Simple shell script parsing ~/.aws/credentials and running aws —profile ${PROFILE} s3 ls should do. Assuming you’ve got CLI credentials for each account in there.

However before going through all that I would ask them what account it is first ;)

1

Using the AWS CLI login to each account and run aws s3 ls and save it to a file. I would name the files using an account key or something else that uniquely identifies each AWS account you have. Then you can grep those files for a bucket name and find which account it belonged to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.