Skip to main content

Introduction

The AWS Command Line Interface (CLI) is a powerful tool for managing AWS services from the command line. This guide covers installation and usage of the AWS CLI, including common commands for managing EC2 instances, S3 buckets, IAM users, DynamoDB tables, and Lambda functions.

Installation

  1. Download and Install AWS CLI
  2. Verify Installation

Basic Configuration

  1. Configure AWS CLI
  2. List AWS CLI Profiles
  3. Get Current AWS CLI Profile
  4. Export Default Profile

Storing Multiple Credentials

  1. Edit the AWS CLI Configuration File: The configuration files are located in ~/.aws/credentials for credentials and ~/.aws/config for configuration. You can edit these files directly or use the aws configure command with the --profile option.
    • Credentials file (~/.aws/credentials):
    • Config file (~/.aws/config):
  2. Add Credentials Using AWS CLI: You can also use the aws configure command with the --profile option to add credentials.
    Follow the prompts to enter the aws_access_key_id, aws_secret_access_key, region, and output.

Using Named Profiles

  1. Specify a Profile for a Single Command: You can specify a profile to use for a single AWS CLI command with the --profile option.
  2. Set a Profile as the Default for a Session: You can set the AWS_PROFILE environment variable to specify which profile to use for the current session.
    • Bash:
    • Windows Command Prompt:
    • PowerShell:

Listing All Profiles

To list all configured profiles, you can use the following command:
This will output a list of all profile names:

Example Workflow

  1. Configure Profiles:
  2. List Profiles:
  3. Use a Specific Profile:
  4. Set a Profile for a Session:
    Now, any subsequent AWS CLI commands will use profile1 credentials until you change the profile or close the session.
By setting up multiple profiles, you can manage and switch between different AWS credentials easily on your local machine.