sodcalculator

10 Tech How-To

How to Use AWS CLI on Windows PC

Guide 10-32230 · Updated · Step by step

This guide walks you through installing and using the AWS Command Line Interface (CLI) on a Windows PC, so you can manage AWS services like S3, EC2, and IAM directly from the command prompt or PowerShell. You’ll learn how to set up the CLI, configure your credentials, and run common commands to interact with your AWS resources.

What You’ll Need

  • A Windows PC (Windows 10 or later recommended).
  • An AWS account (free tier is fine).
  • Your AWS Access Key ID and Secret Access Key (create them in the IAM console if you don’t have them).
  • Administrator rights on your PC to install software.

Step-by-Step

  1. Install the AWS CLI. Download the official AWS CLI MSI installer from the AWS website (search “AWS CLI v2 for Windows”). Run the installer and follow the prompts. By default, it installs to C:\Program Files\Amazon\AWSCLIV2.
  2. Verify the installation. Open a new Command Prompt or PowerShell window (to refresh the PATH) and type aws --version. You should see output like aws-cli/2.x.x Python/3.x.x Windows/10 exe/amd64. If you get an error, see Troubleshooting below.
  3. Configure your credentials. Run aws configure. You’ll be prompted for:
    • AWS Access Key ID – paste your access key.
    • AWS Secret Access Key – paste your secret key.
    • Default region name – e.g., us-east-1 (choose the region closest to you).
    • Default output format – type json (or table if you prefer tables).

    This creates a credentials file at C:\Users\YourUsername\.aws\credentials and a config file at C:\Users\YourUsername\.aws\config.

  4. Test the configuration. Run aws sts get-caller-identity. If everything is set up correctly, you’ll see your AWS account ID, ARN, and user ID in the output. This confirms your credentials work.
  5. Try a simple S3 command. Run aws s3 ls to list your S3 buckets (if you have any). If you don’t have buckets, create one with aws s3 mb s3://your-unique-bucket-name (replace with a globally unique name).
  6. Use the CLI for everyday tasks. For example:
    • Upload a file: aws s3 cp myfile.txt s3://your-bucket/
    • List EC2 instances: aws ec2 describe-instances
    • Get help for any command: aws <service> help (e.g., aws s3 help)
  7. Set up CLI auto-prompt (optional but handy). Run aws configure set cli_auto_prompt on to get interactive suggestions for commands and parameters.
  8. Update regularly. When a new version is released, update by running aws --version then downloading the latest installer from the AWS site, or if you used the MSI, you can re-run the installer to upgrade.

Common Mistakes

  • Not refreshing the PATH. After installation, you must open a new terminal window. If you still get “aws is not recognized,” the PATH may not have been updated. See Troubleshooting.
  • Using the wrong credentials. Make sure you’re using the access key from IAM, not your root account (though root works, it’s not recommended). Also, check that the keys are correctly copied – extra spaces or missing characters cause authentication failures.
  • Setting the wrong region. If you set a region where you don’t have resources, commands like aws ec2 describe-instances will return empty lists, not errors. Always verify your region.
  • Confusing CLI v1 and v2. The commands are mostly the same, but v2 has a different installation method. If you have v1 installed, uninstall it first to avoid conflicts.
  • Forgetting to quote paths with spaces. In PowerShell, if your file path has spaces, wrap it in quotes: aws s3 cp "C:\My Files\data.txt" s3://bucket/.

Tips

  • Use named profiles for different accounts or roles. Run aws configure --profile dev to set up a second profile, then use --profile dev with any command.
  • Leverage the --dryrun flag with S3 commands to preview what would happen without actually executing (e.g., aws s3 cp file.txt s3://bucket/ --dryrun).
  • Set a default output format to table for human-readable output, or json for scripting. You can override per command with --output table.
  • Use the --query parameter to filter output. For example, aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId' returns just the instance IDs.
  • Install the AWS CLI in Windows Terminal or PowerShell 7 for a better experience with syntax highlighting and tabs.

Troubleshooting

  • “aws is not recognized as an internal or external command” – This means the CLI isn’t in your PATH. Re-run the installer and ensure “Add to PATH” is selected (it is by default). If it still fails, manually add C:\Program Files\Amazon\AWSCLIV2 to your system PATH via Environment Variables (search “Edit environment variables” in Start).
  • “Unable to locate credentials” – You haven’t configured your credentials. Run aws configure again, or set environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in a command prompt with setx (but be careful: environment variables are visible to any process).
  • “Access Denied” when calling STS – Your IAM user lacks permissions. Go to the IAM console and attach a policy like AmazonS3ReadOnlyAccess or AdministratorAccess (for testing only).
  • SSL certificate errors – If you’re behind a corporate proxy, you may need to configure the CLI to use a proxy: aws configure set proxy.http_proxy http://proxy:port and similarly for https_proxy.
  • CLI is slow or times out – This is often a network issue. Try increasing the timeout with aws configure set cli_read_timeout 60 and aws configure set cli_connect_timeout 60.
  • Uninstall and reinstall – If all else fails, uninstall the AWS CLI from Control Panel, then download the latest installer and reinstall.

Frequently Asked Questions

Do I need Python to use AWS CLI on Windows?

No. The AWS CLI v2 is a standalone installer that includes its own Python runtime. You don’t need to install Python separately.

How do I switch between multiple AWS accounts?

Use named profiles. Run aws configure --profile account2 to set up a second profile, then use --profile account2 with your commands. You can also set the AWS_PROFILE environment variable to switch the default.

Can I use AWS CLI in PowerShell?

Yes, the AWS CLI works in both Command Prompt and PowerShell. Some commands may have slightly different quoting rules, but generally it works the same.

How do I uninstall AWS CLI?

Go to Settings > Apps > Apps & features, find “AWS Command Line Interface”, and click Uninstall. You can also re-run the MSI installer and choose “Remove”.

Is there a way to get help for a specific command?

Yes, type aws help for general help, or aws s3 help for service-specific help. You can also add help to any command, e.g., aws s3 cp help.

What does “The config profile (default) could not be found” mean?

This means your config file is missing or empty. Run aws configure to set up your default profile again. Check the file at C:\Users\YourUsername\.aws\config to ensure it has content.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →