Open In App

DynamoDB – Setup the AWS CLI on Linux

Last Updated : 01 Aug, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

We can use the AWS Command Line Interface (AWS CLI) to control multiple AWS services from the command line and automate them through scripts. We can use the AWS CLI for ad hoc operations, such as creating a table. We can also use it to embed Amazon DynamoDB operations within utility scripts. Before you can use the AWS CLI with DynamoDB, you must get an access key ID and secret access key.

The AWS CLI is available at http://aws.amazon.com/cli. It runs on Windows, macOS, or Linux. 

Installing the AWS CLI on Linux

The AWS CLI version 2 has no dependencies on other Python packages. It has a self-contained, embedded copy of Python included in the installer.

Prerequisites for Linux:

  • You must be able to extract or “unzip” the downloaded package. If your operating system doesn’t have the built-in unzip command, use an equivalent.
  • The AWS CLI version 2 uses glibc, groff, and less. These are included by default in most major distributions of Linux.
  • It supports the AWS CLI version 2 on 64-bit versions of recent distributions of CentOS, Fedora, Ubuntu, Amazon Linux 1, and Amazon Linux 2.
  • It supports the AWS CLI version 2 on Linux ARM.
  • Because AWS doesn’t maintain third-party repositories, it can’t guarantee that they contain the latest version of the AWS CLI.

Installation:

Follow these steps from the command line to install the AWS CLI on Linux:

  • To download the installer with your browser, use the following URL: https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip
  • Unzip the installer. If your Linux distribution doesn’t have a built-in unzip command, use an equivalent to unzip it. The following example command unzips the package and creates a directory named aws under the current directory.
unzip awscliv2.zip

  • Run the install program. The installation command uses a file named install in the newly unzipped aws directory. By default, the files are all installed to /usr/local/aws-cli, and a symbolic link is created in /usr/local/bin. The command includes sudo to grant write permissions to those directories.
sudo ./aws/install

You can install without sudo if you specify directories that you already have written permissions to. Use the following instructions for the install command to specify the installation location:

  • Ensure that the paths you provide to the -i and -b parameters contain no volume name or directory names that contain any space characters or other white space characters. If there is a space, the installation fails.
  • –install-dir or -i – This option specifies the directory to copy all of the files to. The default value is /usr/local/aws-cli.
  • –bin-dir or -b – This option specifies that the main aws program in the install directory is symbolically linked to the file aws in the specified path. You must have write permissions to the specified directory. Creating a symlink to a directory that is already in your path eliminates the need to add the install directory to the user’s $PATH variable. The default value is /usr/local/bin.
sudo ./aws/install -i /usr/local/aws-cli -b /usr/local/bin

  • Confirm the installation.
aws --version

Updating the AWS CLI on Linux

To update your copy of the AWS CLI version 2, from the Linux command line, follow these steps.

 
  • Downloading from the URL – To download the installer using your browser, use the following URL: https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip. You can verify the integrity and authenticity of the installation file after you download it. 
  • Unzip the installer. If your Linux distribution doesn’t have a built-in unzip command, use an equivalent to install it. The following example command unzips the package and creates a directory named aws under the current directory.
unzip awscliv2.zip

  • To ensure that the update installs in the same location as your current AWS CLI version 2, locate the existing symlink and installation directory, use the which command to find your symlink. This gives you the path to use with the –bin-dir parameter.
which aws
/usr/local/bin/aws

Use your symlink and installer information to construct the install command with the –update parameter.

sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update

  • Confirm the installation.
aws --version

Uninstall the AWS CLI on Linux

To uninstall the AWS CLI version 2, run the following commands:

  • Locate the symlink and install paths. Use the which command to find the symlink. This shows the path you used with the –bin-dir parameter.
which aws
/usr/local/bin/aws

  • Delete the two symlinks in the –bin-dir directory. If your user account has write permission to these directories, you don’t need to use sudo.
sudo rm /usr/local/bin/aws
sudo rm /usr/local/bin/aws_completer

  • Delete the –install-dir directory. If your user account has write permission to this directory, you don’t need to use sudo.
sudo rm -rf /usr/local/aws-cli

 


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads