amazon-web-servicesamazon-s3amazon-ec2aws-cli

Can The AWS CLI Copy From S3 To EC2?


I'm familiar with running the AWS CLI command to copy from a folder to S3 or from one S3 bucket to another S3 bucket:

aws s3 cp ./someFile.txt s3://bucket/someFile.txt

aws s3 cp s3://bucketSource/someFile.txt s3://bucketDestination/someFile.txt

But is it possible to copy files from S3 to an EC2-Instance when you're not on the EC2-Instance? Something like:

aws s3 cp s3://bucket/folder/ ec2-user@1.2.3.4:8080/some/folder/

I'm trying to run this from Jenkins which is why I can't simply run the command on the EC2 like this:

aws s3 cp s3://bucket/folder/ ./my/destination/folder/on/the/ec2

Update:

I don't think this is possible so I'm going to look into using https://docs.aws.amazon.com/cli/latest/reference/ssm/send-command.html


Solution

  • No.

    The AWS CLI calls the AWS API. The APIs for Amazon S3 do not have the ability to interact with the operating system on an Amazon EC2 instance.

    Your idea of using AWS Systems Manager is a good idea. You can send the command to the instance itself, and the instance can then upload/download objects to Amazon S3.