Day 42 of 90 Days of DevOps Challenge: IAM Programmatic Access and AWS CLI

IAM Programmatic Access

Today, we’ll focus on understanding programmatic access to your AWS account using AWS Access Keys. This is essential for automating tasks and managing AWS resources from the command line or scripts.

What is Programmatic Access?

Programmatic access allows you to manage your AWS account via the command line, scripts, or applications by using AWS Access Keys. These keys consist of:

  • AWS_ACCESS_KEY_ID: A unique identifier for your account.

  • AWS_SECRET_ACCESS_KEY: A secret key used to sign requests.

For a more detailed explanation, you can watch this video.


AWS Command Line Interface (AWS CLI)

The AWS Command Line Interface (AWS CLI) is a powerful tool that allows you to manage AWS services from your terminal. It simplifies the process of performing actions on your AWS account and automating tasks through scripts.

Key Features of AWS CLI v2:

  • Improved installation process.

  • New configuration options such as AWS IAM Identity Center (the successor to AWS SSO).

  • Various interactive features for easier usage.


Today's Tasks

Task 1: Create AWS Access Keys

  1. Sign in to AWS Management Console: Go to AWS Management Console.

  2. Navigate to IAM: In the Services menu, select IAM (Identity and Access Management).

  3. Select Users: Click on Users in the left sidebar.

  4. Choose Your User: Click on the user for whom you want to create access keys (if you don't have a user, create a new one).

  5. Security Credentials Tab: Click on the Security credentials tab.

  6. Create Access Key:

    • Click on the Create access key button.

    • Choose the Access key type: Select Access key for CLI, SDK, & other tools.

    • Click on Next to proceed.

  7. Download the Key: You will see your Access Key ID and Secret Access Key. Download the keys or copy them securely. Note: You won’t be able to see the Secret Access Key again after this step.

Task 2: Set Up and Install AWS CLI

Step-by-Step Guide:

  1. Install AWS CLI:

    • For Windows:

    • For macOS:

      • Use Homebrew: Open your terminal and run:

          brew install awscli
        
    • For Linux:

      • Use the following commands:

          curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
          unzip awscliv2.zip
          sudo ./aws/install
        
  2. Verify Installation: After installation, run the following command to verify:

     aws --version
    

  3. Configure AWS CLI:

    • Open your terminal and run:

        aws configure
      
    • Enter the following information when prompted:

      • AWS Access Key ID: (Enter the access key ID you created)

      • AWS Secret Access Key: (Enter the secret access key)

      • Default region name: (Enter the desired region, e.g., us-west-2)

      • Default output format: (Enter json, text, or table; json is recommended)

Test AWS CLI: Run a simple command to verify your configuration:

aws s3 ls

This command lists your S3 buckets (if you have any).

No buckets are listed because I dont have any


Conclusion

Today, you learned how to set up programmatic access to your AWS account by creating access keys and configuring the AWS CLI. This setup enables you to automate tasks, manage resources efficiently, and execute commands directly from your terminal.

The AWS CLI is a powerful tool that significantly enhances your ability to manage AWS services programmatically, making it a vital skill in your DevOps toolkit. Keep exploring, and happy learning! 🌟