Create Amazon Lightsail instance using Python

At the end of November (during the re:invent 2017 event) AWS launched a new service: Amazon Lightsail.
Amazon Lightsail is the easiest way to launch and manage a virtual private server with AWS. With a couple of clicks you can launch a virtual machine pre-configured with SSD storage, DNS management, and a static IP address.
Today you can launch the following operating system:

  • Amazon Linux AMI
  • Ubuntu

or the following developer stack:

  • LAMP
  • LEMP
  • MEAN
  • Node.js

or the following application:

  • Drupal
  • Joomla
  • Redmine
  • GitLab

The following instance plans ara available:


In this post we are going to see how to launch a new Lightsail (MEAN stack) instance using the Python SDK.
If you want to read more about Amazon Lightsail, take a look to the following resource:

We are going to use Python 3.5 and the official Amazon SDK: Boto3 (Boto3 Documentation).
Define a new client for the Lightsail service:

Notice that Lightsail is available only in N. Virginia: Regions and Endpoints – Lightsail

We can now list and print all the available blueprints:

The output will look like this (we need the blueprint id to launch a new instance):

Besides the blueprint, to launch a new instance, we have to specify also the instance type. We can get the available bundles using the get_bundles method:

For each bundle these are the available information (we need the bundleId):

We can now launch a new Lightsail instance (in the example MEAN developer stack and nano instance):

From the Lightsail dashboard we can follow the launch process:

Once the instance is up and running we can connect using SSH (if not specified, the default account key-pair will be used) and deploy our MEAN application.

Check out the public IP of your instance to see the default Bitnami MEAN Stack page.

In this post we saw how to use the AWS API to deploy a MEAN developer stack running in a Lightsail virtual private server.
Lightsail is a new service and is quickly evolving. I suggest you to take a look at it because is a super-fast way to launch development stack for easy deploy (when you do not need high performance and scalability).