Manually Setting Up Multiple AWS Accounts for CLI

It looks like you’ve outlined the steps to manually set up multiple AWS accounts and configure AWS CLI profiles for each account. I’ll provide a more detailed explanation for each step:

1. Get Access Key:

Navigate to the AWS Console:

  • AWS Console > Identity and Access Management (IAM) > Your Security Credentials > Access Keys

Obtain the Access Key ID and Secret Access Key for each AWS account.

2. Set Access File and Content:

Create or edit the AWS credentials file:

~/.aws/credentials

Add the following content:

[default]
aws_access_key_id=your_default_access_key_id
aws_secret_access_key=your_default_secret_access_key


[profile {{profile_name}}]

aws_access_key_id=your_profile_access_key_id aws_secret_access_key=your_profile_secret_access_key

Replace placeholders (your_default_access_key_id, your_default_secret_access_key, your_profile_access_key_id, your_profile_secret_access_key) with your actual values.

3. Set Profile File and Content:

Create or edit the AWS config file:

~/.aws/config

Add the following content:

[default]
region=your_default_region
output=json


[profile {{profile_name}}]

region=your_profile_region output=json

Replace placeholders (your_default_region, your_profile_region) with your actual values.

4. Run File with Params:

Open a terminal and run AWS CLI commands using the configured profiles:

# To use the default profile
aws ec2 describe-instances

# To use a specific profile
aws ec2 describe-instances --profile {{profile_name}}

Replace {{profile_name}} with the name of the profile you want to use.

Additional Notes:

  • Ensure that the AWS CLI is installed on your system before running commands.
  • You can customize the settings in the credentials and config files based on your requirements, such as specifying different regions or output formats.
  • Make sure to keep your AWS credentials secure and do not share them openly.

These steps should help you set up and use multiple AWS accounts with different profiles on the AWS CLI.