AWS CLI with Access Keys

AWS CLI with Access Keys If you work in cloud computing as an SRE, DevOps Engineer, or Cloud Engineer, you know how often the AWS Command Line Interface (CLI) comes in handy. From automating workflows to simplifying troubleshooting, AWS CLI is a tool that makes your life easier. Let’s walk through how to set it…


AWS CLI with Access Keys

If you work in cloud computing as an SRE, DevOps Engineer, or Cloud Engineer, you know how often the AWS Command Line Interface (CLI) comes in handy. From automating workflows to simplifying troubleshooting, AWS CLI is a tool that makes your life easier. Let’s walk through how to set it up with access keys step by step.


Why Use AWS CLI?

AWS CLI is your go-to tool for:

  • Automation: Say goodbye to repetitive tasks by scripting your workflows.
  • Saving Time: Skip the clicks and navigate AWS services directly from your terminal.
  • Flexibility: Run complex commands and configurations without needing the Management Console.

What You Need

Before you start, make sure you have:

  1. An AWS Account with IAM permissions to create access keys.
  2. AWS CLI Installed on your system. Download it here.

Step 1: Generate Access Keys

Here’s how to create your AWS access keys:

  1. Log in to the AWS Management Console.
  2. Go to IAM > Users.
  3. Select the user you want to create access keys for.
  4. Open the Security Credentials tab.
  5. Click Create Access Key.
  6. Save the Access Key ID and Secret Access Key immediately.

Tip: Store these keys securely! You won’t see the Secret Access Key again after you close this step. Use a password manager or a secure notes app to keep them safe.


Step 2: Set Up AWS CLI

Once you have your access keys, configuring AWS CLI is a breeze:

  1. Open your terminal.
  2. Run this command: aws configure
  3. Enter the following details when prompted:
    • AWS Access Key ID: Paste your Access Key ID.
    • AWS Secret Access Key: Paste your Secret Access Key.
    • Default Region: For example, us-west-2 or ap-south-1.
    • Default Output Format: Choose json, table, or text.

Step 3: Verify the Setup

To confirm everything is working, run this command:

This should return details like your IAM user ID, account, and ARN. For example:

{
    "UserId": "ABCDEFGHIJKLMNO",
    "Account": "123456789012",
    "Arn": "arn:aws:iam::123456789012:user/YourUserName"
}

If something doesn’t look right, double-check your credentials and configuration.


Best Practices for Access Keys

Here are a few tips to keep your keys secure and manageable:

  1. Rotate Keys Regularly: Don’t let them sit around forever.
  2. Use IAM Roles: If you’re using EC2, assign an IAM role instead of hardcoding keys.
  3. Secure Your Keys: Never hardcode them in your scripts. Use AWS Secrets Manager or environment variables instead.

Watch the Video Tutorial

Want to follow along with a hands-on demo? Check out this video.



Leave a Reply

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

Related Posts