Last Updates: 5/28/2024
As of this writing the current version of the AWS CLI is …
AWS CLI has been described as a unified tools for managing your AWS resources. In a pinch it can be used to manage S3 data connections as well.
We are going to run through independently hosted S3 server as well as AWS hosts S3 servers.
Version Check:
root@node1:~# aws --version
aws-cli/1.22.34 Python/3.10.12 Linux/5.15.0-102-generic botocore/1.23.34
Windows version:
C:\Users\user>aws --version
aws-cli/2.4.22 Python/3.8.8 Windows/10 exe/AMD64 prompt/off
Install:
$ sudo apt-get install awscli
Clearing Configuration:
To clear out existing AWS configuration it is as simple as removing the configuration files. in Linux it would be as simple as:
root@node1:~# rm ~/.aws/credentials
root@node1:~# rm ~/.aws/config
This section between the above and below horizontal line is reserved.
You can simply say “aws configure” and it will prompt you for common items to set. For the windows command line… you should use the set command.
The following is used to assign the access_key to a user.
C:\Users\user>aws configure set access_key ec2-user
Locally hosted S3 server
NOTE: There is not getting around this. If you are using the AWS CLI and you are using a 3rd party S3 host you are going to have to use “–endpoint-url https://f.q.d.n:9000” i.e. the FQDN and port. AWS does have some config files. But as of 5/29/2024 there still is no way of the AWS client using a value/data pair easy your journey.
Let’s run through an example where you are hosting a S3 server. For example; using Minio. In this example I am hosting an S3 server using Minio on s3.sparelab.net on the default 9000 port.
aws configure set default.s3.signature_version s3v4
One of the first steps you might have is to set your S3 keys.
aws configure set aws_access_key_id <yourAccessKey>
aws configure set aws_secret_access_key <yourSecretKey>
To list a directory
C:\Users\user>aws --endpoint-url http://192.168.160.59:9000 s3 ls thomas
2022-03-02 14:44:43 14 test.txt
Assuming your credentials (accesskey) is set, you can create a bucket with the mb command.
aws --endpoint-url https://s3.sparelab.net:9000 s3 mb s3://mybucket
USING AWS S3:Switching back to using the AWS client with AWS for a second. You might need to clean up some values
note: Buckets are created in the S3 Buckets portal. in us-east2 the url would be: https://us-east-2.console.aws.amazon.com/s3/home?region=us-east-2
Let’s say I set my aw_access “key” to known values I am entered in. (This is not a working key)
aws configure set aws_access_key_id AKIA2YPOKE5YQYMJAYM3
aws configure set aws_secret_access_key 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
and then I unset some values. Some of these might have been used during testing, so please don’t think these are all useful.
root@node1:~/.aws#crudini --del ~/.aws/config default ssl
root@node1:~/.aws# crudini --del ~/.aws/config default host
root@node1:~/.aws# crudini --del ~/.aws/config default hostname
root@node1:~/.aws# crudini --del ~/.aws/config default endpoint_url
The the following will work: public1-test is the name of the bucket in question.
aws s3 ls s3://public1-test
2022-06-29 15:55:51 439 sample.csv
2020-05-10 16:23:45 14 test.txt
2023-03-19 17:37:14 15 test2.txt
2022-06-29 14:43:29 544 transaction.json
2023-03-19 17:45:39 193281097 workspace.tar.gz
Don’t do this. Despite being stupid – the system will allow you to do this.
aws configure set bad good
WIth most configuration values now set and the environment configured you can now easily access items. Example:
aws s3 ls
For Windows: Download
$ aws --version
Installation.
https://awscli.amazonaws.com/AWSCLIV2.msi
Reference URLs:
https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html