sudo yum install pip -y
sudo pip install boto3
touch test.txt
touch upload-s3-usingaccesskey.py
echo "import boto3" > upload-s3-usingaccesskey.py
echo "s3 = boto3.client( 's3', aws_access_key_id='<ACCESSKEY>', aws_secret_access_key='<SECRETACCESSKEY>')" >> upload-s3-usingaccesskey.py
echo "s3.upload_file('test.txt', '<S3BUCKETNAME>', 'test.txt')" >> upload-s3-usingaccesskey.py
python upload-s3-usingaccesskey.py
When we use the access key we are running the application with full S3 service admin rights granted to the IAM user iamaccesskey that we created. Using the above access key will be very dangerous because it is easy to reveal the access key information when we upload the code to public repos like GitHub, for example. Putting the access key directly into the code is not recommended because it leads to security risks, in the next section instead of using the access key, we will try to use the IAM role.