How to connect to an external S3 bucket

Hey guys, I have a friend that is trying to share to me his S3 Bucket so we can work together on some data, the issue is, how do I connect to a bucket that is not in my account/ogranization?

For context, I have a personal account, and he sent me a string with 60 characters saying “this is an access to the resource”, now how can I connect to it so I could import the data in Python?

Most common method I’ve seen is have your friend issue an iam user with a read only policy for the bucket. And then they send you the access key and secret key via email .

How does an IAM user look like?
do I need a username and password, or is it just a signle value that is enough to authenticate and use the shared resource?

He didnt give me that, just a long string, does that mean I should use my own access and secret key? cause I just created an AWS account and I only have an email and password, I didnt get any access/secret key

For context I’m a total noob so I have no idea what is an IAM or whathever and where I get the secret and access key, and help would be gladly apprecciated, thanks

The „cleanest“ way would be:

  • They create Role in their IAM with a trust-relationship that allows your account to assume this role
  • The role on their side allows access to the bucket

Now you can use sts to assume their role and use temporary credentials to access the bucket

Do they need the email of my AWS account for this? And what is sts?

Whoever is hosting the bucket would make an IAM user on their end, and attach to it a policy that allows that user to read/write to the specified s3 bucket . They also generate an s3 access key and secret key that they give to you.

Then you can use that pair of credentials to read and write to that bucket using an s3 client.

If you’re using python you can use boto3 or AWS cli if you want to use command line. All s3 tools require an s3 access key and secret key and the bucket name.

https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-walkthroughs-managing-access-example2.html

Read u/ivanavich’s walkthrough example above.

The AWS Security Token Service (STS) is a service that enables you to request temporary, limited-privilege credentials for AWS Identity and Access Management (IAM) users or for users that you authenticate (federated users).

I predict..you will be one day back here saying…I got a big bill …please help…

It’s probably the easiest, given OP doesn’t seem experienced with AWS.

However, IAM users should be avoided wherever possible and assumable roles should be used instead

I though this myself originally but then it (assuming a role) assumes something about the recipient (the person accessing the files). I.e. they have an AWS account that can assume the role which means the person making the bucket needs to know something from that person (their AWS account, for example, something traceable to an individual).

With S3 access/secret keys, the person issuing them doesn’t have to know anything about the person using them. Which I imagine IS the security issue. But (like IAM roles) they can certainly revoke the access if something is awry.

Unless I’m missing something?

Depends on the trust relationship in the role to be assumed. Given OP has their own AWS account, binding the trust relationship to this account is straight forward.

However, trust relationships are not limited to other AWS account/roles. You can restrict them to identity providers and many more things too.

What about adding your IP to the security group of the S3 to give you access?

Mate before you do anything please set up MFA for your account and a billing alarm. Otherwise in a few months you’ll be back here complaining you have a bill for thousands of dollars.

FOR THE LOVE OF EVERYTHING THAT IS HOLY DO NOT SHARE KEYS.

WTF dude. Are you sure you’re up to this?

Here’s the official docs: https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-walkthroughs-managing-access-example2.html

This is the way!

Yes! This way