0

I want to transfer files from s3 bucket to local, but for some reason I don't have the flexibility to generate credentials for direct access. Instead I have access to an EC2 instance that has access to the s3 bucket. Currently what i did is

  1. transfer files from s3 to ec2
  2. transfer files from ec2 to local

Is there an easier way to transfer files in this situation? for example, use the ec2 as an tunnel to direct transfer files to local without transferring to the ec2 instances.

  • 1
    Simply use scp? https://stackoverflow.com/a/9441027 – Paolo May 14 '22 at 18:59
  • how can i use scp to access files on s3? – user2990604 May 14 '22 at 19:04
  • You use it to copy files from the instance to your local machine – Paolo May 14 '22 at 19:41
  • i know that i can copy files from instance to my local with scp. what i currently do is 1. use aws s3 cp to copy files from s3 to the instance 2. use scp to transfer files from the instance to local my question is: can i avoid 1 (copying files to the instance), but directly transfer to local with something like forwarding or tunneling? – user2990604 May 14 '22 at 19:54
  • You can't because as you mentioned the credentials are attached to the EC2 instance – Paolo May 14 '22 at 20:07
  • You could write a server to serve content from S3, or try using something like s3fs to act as that server for you and access the mount via scp, but whatever solution you come up with bespoke, since this is well outside a normal use case. – Anon Coward May 14 '22 at 20:20

1 Answers1

0

I don’t know if I understood … did you try create an access key and a profile from local machine?

1 - $aws iam create-access-key --user-name

2 - $aws configure --profile tocopy

3 - $aws s3 cp s3://bucket-name/filename.txt ./ —-profile tocopy

Ps: tocopy is any string to named your profile.

If these steps doesn’t work, you need see ACL, Policy or others access control on your bucket. ;-) Tip: on your user apply an policy with get and list to your bucket.

Ps: if you need copy many times, I should you use: $aws s3 syn s3://bucket-name/filename.txt ./ —-profile tocopy