How to upload/download to S3 from a EC2 instance

Software Engineer at BMW, Oracle Certified Professional Java SE 11 Developer
Search for a command to run...

Software Engineer at BMW, Oracle Certified Professional Java SE 11 Developer
No comments yet. Be the first to comment.
Two whole days of my life, down the drain! Thankfully, it was just my pet project, but I ended up sacrificing an entire weekend wrestling with this enigma. So, I'm writing this blog post to save you from the same fate. Problem: I am using Quarkus and...

Shebang Shebang is a combination of bash # and bang ! followed the the bash shell path. Shebang is simply an absolute path to the bash interpreter. #! /bin/bash Make a file executable To make a .sh file executable only for your user, use: chmod u+x...

1. Show tables The command \dt stands for describe tables and shows all tables in the database, equivalent to show tables in MySQL. \dt 2. Create user Run the following SQL command to create a user. Replace and 'password' with the desired username a...

How to set JAVA_HOME on macOS Monterey? First check which shell you are using (either bash or zsh). For zsh shell, we can put the environment variables at ~/.zshenv or ~/.zshrc.echo $SHELL /bin/zsh On Mac OS X 10.5 or later, we can use /usr/libexe...

Fork your open source project you want to contribute into your GitHub and clone your fork. git clone git@github.com:dcnis/mockito.git Show current configured remote repositories. The origin repo points to your fork on GitHub. git remote -v > origin ...

I recommend creating a separated user for uploading to your S3 bucket.
IAM -> Users -> Add userUser name: s3_userPermission options: Attach policies directlyAmazonS3FullAccessNext -> Create userWe need to create an access_key and secret_key in order to use our s3_user within the aws command.
s3_user and go to Security credentialsCreate access keyApplication running on an AWS compute serviceCreate access keyAccess key and Secret access keyaws configure --profile s3_user
AWS Access Key ID [None]: <your_access_key>
AWS Secret Access Key [None]: <your_secret_access_key>
Default region name [None]: eu-central-1
Default output format [None]: json
Now you can upload a file to your S3 bucket using your new profile
aws s3 cp /opt/test.txt s3://mybucketname/test.txt --profile s3_user
aws s3 cp s3://mybucketname/test.txt /opt/test.txt --profile s3_user
In this article we have learned how to configure an user and the aws cli to conveniently upload and download files from S3 to your EC2 instance.