Install AWS CLI on Windows with winget: Quick Setup Guide
Install AWS CLI v2 on Windows using winget in one command. Configure credentials, set up PowerShell autocomplete, and verify with Terraform.
DevOps
Install AWS CLI v2 on Ubuntu 22.04 and 24.04 using the official installer, snap, or pip. Configure credentials, test with Terraform, and set up autocomplete.
The AWS CLI is required for many Terraform workflows — configuring credentials, debugging, and managing state backends. Here's how to install AWS CLI v2 on Ubuntu.
# Download
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
# Install unzip if needed
sudo apt-get update && sudo apt-get install -y unzip
# Extract and install
unzip awscliv2.zip
sudo ./aws/install
# Verify
aws --version
# aws-cli/2.17.x Python/3.12.x Linux/6.x.x
# Clean up
rm -rf awscliv2.zip aws/curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/installsudo snap install aws-cli --classic
aws --versionSimple, auto-updates. Slightly slower startup than the native binary.
# Not recommended — can conflict with system packages
pip3 install awscliUse this only in virtual environments or containers.
# ❌ This installs AWS CLI v1 (outdated)
sudo apt install awscli
aws --version
# aws-cli/1.x.x — OLD, missing v2 featuresUbuntu's default awscli package is v1. Always use the official installer for v2.
aws configure
# AWS Access Key ID [None]: AKIA...
# AWS Secret Access Key [None]: ****
# Default region name [None]: us-east-1
# Default output format [None]: jsonCreates ~/.aws/credentials and ~/.aws/config.
aws configure --profile production
# AWS Access Key ID: AKIA...
# ...
# Use with Terraform
export AWS_PROFILE=production
terraform planaws configure sso
# SSO session name: my-org
# SSO start URL: https://my-org.awsapps.com/start
# SSO Region: us-east-1
# Login
aws sso login --profile my-org
# Use with Terraform
export AWS_PROFILE=my-org
terraform plan# Bash
echo 'complete -C aws_completer aws' >> ~/.bashrc
source ~/.bashrc
# Zsh
echo 'autoload -U +X bashcompinit && bashcompinit' >> ~/.zshrc
echo 'complete -C aws_completer aws' >> ~/.zshrc
source ~/.zshrc# Check AWS identity
aws sts get-caller-identity
# {
# "UserId": "AIDA...",
# "Account": "123456789012",
# "Arn": "arn:aws:iam::123456789012:user/myuser"
# }
# Terraform uses the same credentials
terraform init
terraform plan# Official installer — re-run with --update
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update
rm -rf awscliv2.zip aws/
# Snap
sudo snap refresh aws-cliFROM ubuntu:24.04
RUN apt-get update && \
apt-get install -y curl unzip && \
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install && \
rm -rf awscliv2.zip aws/ && \
apt-get clean && rm -rf /var/lib/apt/lists/*# Check install location
which aws
ls -la /usr/local/bin/aws
# If not in PATH
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc# Check for credentials
aws configure list
# If all "not set" — run aws configure
# Check environment variables
env | grep AWS_sudo apt-get install -y ca-certificatesUse the official AWS installer for CLI v2 on Ubuntu — it's always current and doesn't conflict with system packages. Avoid apt install awscli (it's v1). Configure credentials with aws configure or SSO for organizations. Terraform automatically uses the same ~/.aws/credentials that the CLI uses.
Install AWS CLI v2 on Windows using winget in one command. Configure credentials, set up PowerShell autocomplete, and verify with Terraform.
Install Terraform on Amazon Linux 2023 using the HashiCorp repository or manual binary download. Verify installation, configure autocomplete
Install Terraform on Debian 12 Bookworm using the HashiCorp APT repository or manual binary download. Includes verification, autocomplete setup
Install and manage multiple Terraform versions with tfenv. Switch between versions per project, auto-detect from .terraform-version files