Configuring the AWS CLI: A Beginner's Guide to Cloud Access
Master the AWS CLI configuration process. Learn how to install the tool, manage your credentials securely, and verify your connection to the AWS cloud.
Previously in this course, we explored the AWS Global Infrastructure Overview: Regions and Availability Zones to understand where our resources live. Now that you know where your infrastructure resides, it’s time to learn how to control it.
The AWS Command Line Interface (CLI) is the primary tool for interacting with AWS services from your terminal. Whether you are automating deployments or inspecting resources, the AWS CLI is the "Swiss Army knife" of a DevOps engineer.
Installing the AWS CLI
Before we can interact with AWS, we need the tool installed. AWS provides unified installers for Windows, macOS, and Linux.
- For macOS: Use
brew install awscliif you have Homebrew installed. - For Windows: Download the MSI installer from the official AWS website.
- For Linux: Download the zip file, unzip it, and run the
sudo ./aws/installscript.
Once installed, verify it by running:
Bashaws --version
If you see a version output (e.g., aws-cli/2.x.x), you are ready for configuration.
Configuring Credentials with Access Keys
The AWS CLI needs to authenticate as a user to perform actions. We do this using an AWS Access Key ID and a Secret Access Key.
Warning: Never hardcode these keys in your scripts or push them to version control.
To configure your machine, run the following command in your terminal:
Bashaws configure
The CLI will prompt you for four pieces of information:
| Prompt | What to enter |
|---|---|
| AWS Access Key ID | Paste the ID provided by your IAM user creation. |
| AWS Secret Access Key | Paste the secret key (treat this like a password). |
| Default region name | Use the region you selected in our first lesson (e.g., us-east-1). |
| Default output format | Set this to json. |
This command creates a hidden directory in your home folder (~/.aws/) containing two files: credentials and config. These files store your keys and your preferred region, respectively.
Verifying Connectivity
Now that you've configured your credentials, let's verify that your local machine can "talk" to AWS. We will use the sts (Security Token Service) command, which returns information about your identity.
Run this command:
Bashaws sts get-caller-identity
If everything is configured correctly, you will receive a JSON response:
JSON{ "UserId": "AIDAX...", "Account": "123456789012", "Arn": "arn:aws:iam::123456789012:user/your-username" }
If you see an "Access Denied" or "Invalid Client Token" error, double-check that your keys were copied correctly without any leading or trailing spaces.
Hands-on Exercise
To practice, try listing the S3 buckets in your account. Even if you haven't created any yet, running the command proves your permissions are active.
- Run:
aws s3 ls - If the command returns nothing (or a list of buckets), your configuration is functional.
- If you get an error, re-run
aws configureand ensure your keys are valid.
Common Pitfalls
- Expired Keys: If your keys were generated a long time ago, they might have been deactivated by an administrator. Always generate new keys if you suspect they are stale.
- Permissions Issues: Even with valid keys, you might not have access to specific services. This is a matter of IAM Policies, which we will cover in the next lesson.
- Multiple Profiles: If you work with multiple AWS accounts, you don't need to re-run
aws configure. You can use named profiles:aws configure --profile prod. You then access them viaaws s3 ls --profile prod.
Frequently Asked Questions
Q: Where are my keys stored?
A: On Linux/macOS, they are in ~/.aws/credentials. On Windows, they are in C:\Users\USERNAME\.aws\credentials.
Q: Can I use environment variables instead?
A: Yes. You can set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in your shell profile. Environment variables take precedence over the ~/.aws/credentials file.
Q: Is it safe to store keys in ~/.aws/?
A: It is generally safe for local development, provided your machine is encrypted and secured. Never commit these files to GitHub.
Recap
We’ve successfully installed the AWS CLI, mapped your credentials to your local environment, and verified your connection with the sts service. You are now prepared to manage your infrastructure programmatically.
Up next: We will dive into IAM Users and Policies to understand how to restrict and grant permissions securely.
Work with me

CI/CD Pipeline & Docker Containerization
Ship with confidence: automated CI/CD pipelines and Docker setups so every push is tested and deployed — no more manual, error-prone releases.

VPS Server Setup, Deployment & Hardening
Get your app live on a fast, secure server — properly configured, hardened, and deployment-ready. No more wrestling with the command line.