AWS CLI Tutorial 2- AWS CLI Configuration and AWS Credentials Setup

3 min read 1 year ago
Published on Aug 02, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial will guide you through the process of configuring the AWS CLI (Command Line Interface) to access your AWS account securely. You'll learn how to create AWS credentials, set up the CLI, and ensure everything is configured correctly for your development needs.

Step 1: Create an IAM User in AWS Console

To access AWS services through the CLI, you'll need to create an IAM (Identity and Access Management) user with programmatic access.

  1. Go to the AWS Management Console at aws.amazon.com.
  2. Search for and select "IAM" from the services menu.
  3. Click on "Users" in the IAM dashboard.
  4. Click the "Add user" button.
  5. Enter a username (e.g., kgptoki).
  6. Select the access type:
    • Choose "Programmatic access" to create an access key ID and secret access key.
  7. Click "Next" to set permissions.
  8. Choose permissions for the user:
    • For learning purposes, select "AdministratorAccess" to grant full access to AWS services.
    • Alternatively, select specific services as needed.
  9. Click "Next" and review your settings.
  10. Click "Create user" to finish.

Once the user is created, make sure to copy the Access Key ID and Secret Access Key for later use.

Step 2: Install and Configure AWS CLI

Now that you have your IAM user set up, it's time to configure the AWS CLI.

  1. Open your command line interface (CLI).

  2. Type the following command to initiate the configuration:

    aws configure
    
  3. When prompted, enter the following information:

    • Access Key ID: Paste your newly created access key ID.
    • Secret Access Key: Paste your secret access key.
    • Default region name: Specify your preferred AWS region (e.g., us-east-2).
    • Default output format: Choose your preferred format for CLI output (e.g., table, json, or text; table is recommended for readability).
  4. Press Enter after each input to complete the configuration.

Step 3: Verify Configuration

After setting up the CLI, it's important to verify that everything is working correctly.

  1. Run a simple AWS CLI command to check connectivity:
    aws s3 ls
    
    This command lists your S3 buckets. If configured correctly, you'll see your buckets listed or a message indicating that you have none.

Conclusion

You have successfully configured the AWS CLI to access your AWS account. With your IAM user created and the CLI configured, you can now interact with AWS services directly from your command line. For further exploration, consider trying additional AWS CLI commands or diving into AWS services relevant to your projects.