Create an IAM role for your use cases e.g. serverless-admin
You don't want to give the serverless-admin access to all feature of aws. Therefore you create a new IAM user that only has the rights a serverless developer needs e.g. access to AWS Lambda, Dynamodb, S3, API Gateway, CloudDeployment and Logs. You use this user for the AWS CLI and the Serverless framework.
sudo pip install awscli
# use the access key id and secret access ky as describe above
aws configure
# AWS Access Key ID [None]: AKIAI44QH8DHBEXAMPLE
# AWS Secret Access Key [None]: je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
# Default region name [None]: eu-central-1
# Default output format [None]:
# for the man pages do
aws configure help
Securely store your keys and secrets in your rsh file
You don't want to store your secrets in plain text in a file like .rshrc therefore you can use lpass cli [github / documentation] and store your secrets in your osx keychain and access them only by reference.
Installation
brew install lastpass-cli --with-pinentry
Set variables in lastpass
Just create a secret note within lastpass:
Login to lpass in the command line
# login to lastpass
# check first if I am allready loggedin and finded the "access-token" folder
if [[ $(lpass ls) != *"access-token"* ]]; then
lpass login your@email.com
fi
Set environment variable (e.g. key_id (username) and secret(password)
export AWS_ACCESS_KEY_ID=$(lpass show aws-serverless-devops --username)
export AWS_SECRET_ACCESS_KEY=$(lpass show aws-serverless-devops --password)