shou2017.com
JP

Using multiple AWS profiles with Serverless Framework

Tue Jun 9, 2020
Sat Aug 10, 2024
AWS

When developing on AWS, it’s common to use multiple accounts, such as a development account and a production service account.

Here, what’s convenient is the AWS CLI profile.

By using this, you can build separate environments for each account.

It’s easy to use. Use the --profile option to create a profile named produser.

$ aws configure --profile produser
AWS Access Key ID [None]: AKIAI44QH8DHBEXAMPLE
AWS Secret Access Key [None]: je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: text

To use this profile with serverless framework, just do the following. This way, you can document multiple profiles, making it simple.

service: sls-layer

provider:
  name: aws
  runtime: nodejs12.x
  profile: produser

Reference

See Also