You'll first need to use the AWS CLI to set up a new profile with an existing AWS IAM access keys into
(You can also manually add new profiles and access keys directly into
The Serverless CLI (and other AWS CLIs, like the Amplify CLI) uses the AWS IAM access keys in
~/.aws/credentials to perform deploys.
AWS CLI is written in Python so you'll need to install Python 3 to get this set up.
It is recommended to install Python via a Version Manager (See: Why Not Use System Python?.)
I wrote another post about setting up a Python dev environment
Follow the docs to install the AWS CLI.
Verify the AWS CLI is available:
$ which aws
Note: If you run
which awsand it returns
aws not found- try reloading your bash environment.
- Go to your AWS > My Security Credentials. (For future reference, this is under your AWS Console > Account Menu Dropdown)
- Click: Create access key
- You will be shown your
Access Key IDand
Secret Access Key. Keep this window open. You will need this in the next steps.
You will need the
Access Key ID and
Secret Access Key here.
$ aws configure --profile devProfile
AWS Access Key ID [None]: YOUR_ACCESS_KEY_ID AWS Secret Access Key [None]: YOUR_SECRET_ACCESS_KEY Default region name [None]: us-west-2 Default output format [None]: json
aws configure will set up the
.aws/ folder in your root directory:
(root) └── .aws/ ├── config // Your AWS Profiles └── credentials // Your access key pairs
Let's verify that your creds have been added correctly...
# This will print your creds to the console. $ cat ~/.aws/credentials # If your console print-out includes the below, you're good-to-go! [devProfile] aws_access_key_id = XXXXX aws_secret_access_key = XXXXX
⚠️ The entry
[profile devProfile]must also exist in
~/.aws/config. These are also used in other AWS CLIs like Amplify CLI.
$ cat config # Output: [profile devProfile] region=us-west-2 output = json
There are several different ways to choose which AWS profile you want to use with Serverless CLI:
profile setting to
provider configuration in
service: new-service provider: name: aws runtime: nodejs12.x stage: dev profile: devProfile # Specify the profile here
You can switch the AWS profile per project executing once when you start your project:
Run an npm script for:
export AWS_PROFILE="devProfile" && export AWS_REGION=us-west-1.
Or manually pass the AWS profile as an option to the Serverless CLI command with the
$ serverless deploy --aws-profile devProfile
Read more at the Serverless Docs.
$ lumigo-cli switch-profile