Docker Tutorial

How to Configure AWS CLI with Access Keys and Region (Step-by-Step Guide)

🪜 Step 8: Configure AWS CLI (Get and Set Up Your Access Keys)

Before pushing your Docker image to AWS (like Amazon ECR), you must configure the AWS CLI on your Ubuntu or WSL terminal.

When you run:

aws configure

You’ll be prompted to enter four details — here’s what each one means and how to get them 👇


🧩 1️⃣ AWS Access Key ID

  • This is your public key that identifies your AWS account.
  • You can find or create it from your AWS Management Console:

Steps:

  1. Log in to your AWS Console.
  2. Go to the IAM (Identity and Access Management) service.
  3. Click Users → select your username.
  4. Under the Security credentials tab, find the section named Access keys.
  5. Click Create access key.
  6. You’ll get:
    • Access key ID (looks like AKIAxxxxxxxxxxxxxx)
    • Secret access key (keep it private!)

⚠️ Important: Copy and store both keys securely (e.g., in a password manager). You won’t be able to see the secret key again later.


🧩 2️⃣ AWS Secret Access Key

  • This is your private key used to authenticate commands.
  • You’ll get it only once when you create the key in IAM.
  • Never share it publicly or commit it to GitHub!

When prompted in your terminal, paste it carefully.


🧭 3️⃣ Default Region Name

This tells AWS which data center region you’ll use by default.

For example:

  • ap-south-1 → Mumbai (India)
  • us-east-1 → North Virginia (USA)
  • eu-west-1 → Ireland

✅ If you’re in India, type:

ap-south-1

📦 4️⃣ Default Output Format

This defines how AWS CLI shows results in your terminal.

You can choose:

  • json → machine-readable format (recommended)
  • text → plain text
  • table → table-style output

✅ Type:

json

✅ Example

Here’s what a complete setup looks like:

$ aws configure
AWS Access Key ID [None]: AKIAEXAMPLE12345
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: ap-south-1
Default output format [None]: json

After this, your credentials are saved in:

~/.aws/credentials

🎯 That’s It!

Your AWS CLI is now configured and ready to:

  • Push Docker images to Amazon ECR
  • Deploy apps to EC2
  • Manage AWS resources directly from your terminal!

 

Leave a Reply

Your email address will not be published. Required fields are marked *