Installing the AWS and Serverless CLI
In order to get started, you first need to install the AWS CLI and the Serverless CLI onto your computer. You do both typing the following into your terminal:
npm install -g aws-sdk npm install -g serverless
The Serverless Framework allows us to easily deploy our code onto AWS's plateform. In order to do that we need to give serverless some sort of AWS credentials, otherwise it will be blocked from doing anything.
Creating a Serverless User in AWS
Every developer will have an AWS user assigned to them called
This will be the user you use to deploy your own version of our apps services to AWS. All resources will have yourName-dev appended to it. Ask the team lead to make your serverless user with programatic admin access.
Adding credentials onto your computer
On a mac, AWS credientials are stored in
This file will store all of your credentials, and with many aws profiles will look something like this:
[default] aws_access_key_id = ... aws_secret_access_key = ... [work-dev] aws_access_key_id = ... aws_secret_access_key = ... [work-prod] aws_access_key_id = ... aws_secret_access_key = ...
I would recommend you leave the default spot for your own personal AWS account user, and make profiles specifically for work. In order do make a work-dev user, write the following serverless command:
sls config credentials --provider aws --key YOUR_KEY --secret YOUR_SECRET --profile work-dev
If you open your .aws/credentials file, you should see your work-dev profile listed.
Deploying Serverless Projects with your work credentials
In the package.json file in each service, you will see these scripts included:
"deploy": "serverless deploy --aws-profile work-dev", "deploy-prod": "serverless deploy --stage prod --aws-profile work-prod",
Deploy will execute the serverless deploy command using your work-dev aws profile, and deploy-prod will deploy production versions if you have a work-prod profile.
The Big Picture
There are 2 AWS environments, 1 for development with dev resources (light grey boxes), which each developer has access to, and another for all other stages such as staging, testing, and production.