- Serverless Programming Cookbook
- Heartin Kanikathottu
- 497字
- 2025-04-04 15:02:17
Configuring AWS CLI
We can use pip or pip3 to install AWS CLI.
You use pip or pip3 to install AWS CLI as:
pip install awscli --upgrade --user
Pip is a Python package management tool that can be installed along with Python. You may replace pip with pip3 if you have installed pip3. The --upgrade option upgrades any installed requirements. The --user option installs the program to a sub-directory of your user directory to avoid modifying libraries used by operating system.
We can configure our AWS credentials in our local machine by running aws configure. This will setup a default AWS profile. You can have more named profiles if you want.
Run the below command to configure AWS CLI for the default profile. If aws command is not recognized, you will need to add it to the path.
aws configure
Provide your AWS Access Key ID, AWS Secret Access Key, Default region name, and Default output format:

AWS Access Key ID and AWS Secret Access Key is generated by AWS when you create a user with programmatic access. We had created an user and generated these credentials in the recipe Getting started with the AWS platform. You can also regenerate them later if you forget or miss them following the below steps:
- Log in to AWS.
- Go to IAM service.
- Click on Users from the sidebar. This will show you the user summary page.
- From within the user summary page, click on Security Credentials tab.
- Click on Create access key to create a new key. You may make the old key inactive or delete it.
The AWS Access Key ID and AWS Secret Access Key entered is stored in a file, ~/.aws/credentials, and the region name and output format is stored in a file, ~/.aws/config.
Verify the configuration as given as follows:
cat ~/.aws/credentials

And next, run cat ~/.aws/config:

AWS documentation recommends creating a named profile for your admin user (for instance, a user with administrator access policy) and then using it with AWS CLI. You can add an additional profile in ~/.aws/credentials, as shown here:

You can add an additional profile by editing the file ~/.aws/config, as shown here:
