Setup virtual machine for Amazon Web Services CLI, Local DynamoDB and Serverless Framework

AWS Virtual Machine

If your host machine is not a linux-based OS, please download VirtualBox and Vagrant to setup a Virtual Linux Host OS.

This guide will be used to install and config docker on Macbook with a Virtual Linux Host OS of Ubuntu/trusty (VirtualBox+Vagrant). I suggest to use iTerm for terminal replacement.

Setup Virtual Machine

  • Step 1: Install Virtual Box - version 4.3.30 (

  • Step 2: Install Vagrant 1.7.4 (

  • Step 3: Create a folder for virtual machines
    mkdir ~/VMS
    mkdir ~/VMS/aws
  • Step 4: Create an Ubuntu virtual machine
cd VMS/aws
vagrant init ubuntu/trusty64; vagrant up --provider virtualbox
  • Step 5: Prepare folder structure
Source code on my laptop: ~/Source

DevOps on my laptop: ~/DevOps (please clone the source from

Virtual Machines on my laptop: ~/VMS
  • Step 6: Edit the Vagrantfile to config virtual machine

Setup the IP Address for the guest VM. I will use the address

# Create a private network, which allows host-only access to the machine
# using a specific IP. "private_network", ip: ""

Share additional folders to the guest VM

config.vm.synced_folder "~/Source", "/var/www/html", :mount_options => ['dmode=777', 'fmode=777']
config.vm.synced_folder "~/DevOps", "/Devops"

Increase memory for guest VM for 3GB Ram

config.vm.provider "virtualbox" do |vb|
  vb.memory = "3072"

Reload vagrant to apply new config

vagrant reload

Setup NodeJS, Java Runtime and AWS CLI

  • Step 1: Log in to the guest VM and switch to root user
cd ~/VMS/aws
vagrant up
vagrant ssh

When you are inside the virtual machine, switch to root user

sudo -s
  • Step 2: Install NodeJS and Java Runtime

Update Ubuntu

apt-get update

Install NodeJS

curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

Install Java Runtime

sudo apt-get install default-jre
  • Step 3: Install PIP
cd /tmp
curl -O
sudo python
  • Step 4: Install AWS CLI
sudo pip install awscli
sudo pip install --upgrade awscli
  • Step 5: Setup default profile for AWS Cli
aws configure

If you want to configure for another profile, you should add this param to above command

aws configure --profile name_of_the_profile

You will be asked to supply your AWS Access Key ID and Secret Access Key. You need to create AWS user and assign role to that user in AWS Console online.

alt text

AWS Secret Access Key [None]: je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: text

Note: Above info is just sample data.

Your AWS Credentials and Config are saved at ~/.aws/credentials and ~/.aws/config

Learn more at:

AWS Security Best Practices:

Setup Local DynamoDB

  • Step 1: Download DynamoDB and Install DynamoDB run at port 6868
cd /bin
mkdir dynamodb
tar -xf dynamodb_local_latest.tar.gz -C dynamodb
cd dynamodb
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb -port 6868

(You can set your own port to run local DynamoDB instead of above port)

  • Step 2: Check local DynamoDB work

Visit (Use IP of your virtual machine)

alt text

Setup Serverless

  • Install NodeJS and NPM
curl -sL | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install npm

  • Install The Serverless Framework via npm: (requires Node V4)
npm install serverless -g

Setup Time for preventing issues with signatures of making requests to Amazon

sudo ntpdate
  • Update the Serverless Framework to a verion (v0.5 for example)

If you don’t have git, install it first

apt-get update
apt-get install git
npm install -g git://

That’s it. Happy coding and Feel free to contact me.

Written on February 19, 2016