The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.
The AWS CLI v2 offers several new features including improved installers, new configuration options such as AWS Single Sign-On (SSO), and various interactive features.
The CLI package has been tested on macOS versions 10.9 and later. The current version of the Azure CLI is 2.14.0. For information about the latest release, see the release notes. To find your installed version and see if you need to update, run az -version. Install with Homebrew. Homebrew is the easiest way to manage your CLI install. AWS Management Console is incredible, but using the Command Line Interface open infinity possibilities. Let's check how to install, configure, and run AWS CLI commands. On-demand access to all your files stored in WorkDocs in familiar Windows Explorer and Mac Finder, without using up your device storage. Synchronize change, search and work offline for your Amazon WorkDocs files. The AWS Tools for PowerShell lets you perform many of the same actions available in the AWS SDK for.NET. You can use it from the command line for quick tasks, like controlling your Amazon EC2 instances.
Windows
Download and run the 64-bit Windows installer.
MacOS
Download and run the MacOS PKG installer.
Linux
Download, unzip, and then run the Linux installer
Amazon Linux
The AWS CLI comes pre-installed on Amazon Linux AMI.
Release Notes
Check out the Release Notes for more information on the latest version.
aws-shell is a command-line shell program that provides convenience and productivity features to help both new and advanced users of the AWS Command Line Interface. Key features include the following.
- Fuzzy auto-completion for
- Commands (e.g. ec2, describe-instances, sqs, create-queue)
- Options (e.g. --instance-ids, --queue-url)
- Resource identifiers (e.g. Amazon EC2 instance IDs, Amazon SQS queue URLs, Amazon SNS topic names)
- Dynamic in-line documentation
- Documentation for commands and options are displayed as you type
- Execution of OS shell commands
- Use common OS commands such as cat, ls, and cp and pipe inputs and outputs without leaving the shell
- Export executed commands to a text editor
To find out more, check out the related blog post on the AWS Command Line Interface blog.
The AWS Command Line Interface User Guide walks you through installing and configuring the tool. After that, you can begin making calls to your AWS services from the command line.
You can get help on the command line to see the supported services,
New file commands make it easy to manage your Amazon S3 objects. Using familiar syntax, you can view the contents of your S3 buckets in a directory-based listing.
You can perform recursive uploads and downloads of multiple files in a single folder-level command. The AWS CLI will run these transfers in parallel for increased performance.
A sync command makes it easy to synchronize the contents of a local folder with a copy in an S3 bucket.
See the AWS CLI command reference for the full list of supported services.
Connect with other developers in the AWS CLI Community Forum »
Find examples and more in the User Guide »
Learn the details of the latest CLI tools in the Release Notes »
Dig through the source code in the GitHub Repository »
VOIDKAT
March 01, 2019
Some common AWS S3 CLI commands to manage files on S3 buckets. I will explain how to install the AWS CLI, set up your credentials, sync files, delete, upload and download.
Install CLI
Download AWS CLI from Amazon. Install to your system.
Set up your credentials
Once AWS CLI is installed you will need to configure it with your credentials to be able to work with your S3 buckets. Run the following command.
aws configure
You will need to enter the following:
To get these credentials login to AWS Console and go to Security Credentials and create them according to IAM Best Practices. Once completed this will allow AWS CLI to communicate with your S3 buckets.
Managing multiple AWS credentials
If you manage several AWS accounts, its best to setup Named profiles
to manage your various AWS CLI credientails. Open your AWS credentials files
~/.aws/credentials (Linux & Mac) or %USERPROFILE%.awscredentials (Windows)
Then add the various accounts:
Save and close the file. You will now be able to run AWS CLI commands with specific named profiles. For emxaple:
aws s3 ls --profile user1
See the official docs for Named Profiles
Being safe when running AWS CLI commands
It is recommended to add --dryrun
parameter flag before running AWS CLI commands which will display the operations without actually running them. This is good for debugging and being sure of the commands you want to execute.
Bucket wide commands
List AWS S3 buckets
To list AWS S3 buckets run:
aws s3 ls
Creating an S3 bucket
To create an S3 bucket, run:
aws s3 mb s3://bucket-name
Keep in mind that bucket names are unique across AWS.
Successful creation will return make_bucket: bucket-name
Deleting an S3 bucket
To delete an S3 bucket, run:
aws s3 rb s3://bucket-name
Successful creation will return remove_bucket: bucket-name
Download S3 buckets contents
To download S3 bucket contents to local system use the following command
aws s3 sync s3://bucket-name .
The following command will download the contents to the current local folder.
Upload local contents to S3 bucket
To upload local file contents to the S3 bucket run the following command
aws s3 sync . s3://bucket-name
Deleting files and updating S3 bucket
If you delete files locally and want the S3 bucket to also delete files you have to add the --delete
parameter flag.
aws s3 sync . s3://bucket-name --delete
I recommend adding the --dryrun
flag and running the command to make sure you are deleting exactly what you want.
Deleting files and updating S3 bucket
File commands
Copy one file to bucket
To copy a single file to an S3 bucket use the following command
aws s3 cp filename s3://bucket-name
Delete one file from bucket
To delete a single file from an S3 bucket
aws s3 rm s3://bucket-name/filename
Note: if you delete a file locally, and attempt to sync, the file will not be deleted on the S3 bucket without a --delete
flag added to the sync command.
Setting permissions
When uploading files especially for static public sites use the --acl
parameter. e.g.
aws s3 cp filename s3://bucket-name --acl public-read
e.g.
aws s3 sync . s3://my-bucket/path --acl public-read
Further commands
See the full documentation for high level CLI commands here Using High-Level (s3) Commands with the AWS CLI. For full documentation for sync on the AWS Docs page
Download Aws Cli Tools For Windows
Written by Farhad Agzamov who lives and works in London building things.You can follow him on Twitterand check out hisgithub here