Cloud Computing Jump Start with AWS Lightsail

Deploying Services on Lightsail

In the recent past if you wanted to deploy an infrastructure type service in AWS you started with an EC2 instance. From your instance you installed your service and went from there. An example of this would be Wordpress or even your own Git Lab instance. AWS now has a service called Lightsail which greatly simplifies the overhead of getting up and running in the cloud. In just a few clicks can have a service up and running on a server with a static ip and even an in browser ssh shell.

Lightsail Permissions

The first thing that you will need is permission to use the Lightsail service. This is actually not as simple as is sounds which is part of the reason I'm sharing this with you. If you try to access the Lightsail service directly you will be likely be deined.

Back to IAM

AWS recommends not using your root account and to further lock it down via multi-factor authentication. This will leave you to make an IAM user. You'll inevitabbly want to give that user permissions but AWS only allows any user ten permissions at a time. To get around this I suggest using groups and then adding that user to various groups to inherit their permissions. Lightsail doesn't have a standard permission, but you can make your own by looking at the left hand side bar in the IAM menu. Click "Policies" and then use the blue button "Create Policy" to get started. We are going to make a custom policy from raw json, so be sure to click the json tab here.

Paste in the raw JSON.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "lightsail:*" ], "Resource": "*" } ] }

If you now head back over to the Lightsail service you'll see that you have access now.

You'll see all the services that can be started below. I'm going to start Wordpress so you can see what it's like to interact with Lightsail.

Once it's up and running you'll see that it has been assigned a public and private ip.

Managing Wordpress via Lightsail

When your Wordpress instance first launches it will not take you to the typical Wordpress configuration page where you would make a user and and password. Instead follow the public ip that is generated for you in your browser and click the "manage" icon in the lower right corner as seen here.

This will show you the user name that was created for you on boot, but cleverly not the password. The password is also created for you at boot time and to get it you can use the Lightsail Browser shell. This is a shell that is similar to Putty but runs right in the browser. There are some real time saving up sides here. The first is if you start the ssh system from the Lightsail console you won't need any authentication. You will go straight to the command line. The second is Amazon has organized the installation to make it simple to facilitate customization that you would likely want. However, the first thing we want is the admin password and you can get it with the command cat bitnami_application_password. Here is what it looks like

What About the Database?

The database is a central part of Wordpress so accessing the associated tables is important. However, just like the password this is not intuitive at all. At this point you'll want to make sure you have the private key that you generated when you started your Lightsail instance. Then from the command line (for security reasons!) you'll need to make a tunnel to your localhost. It sounds complicated, but to keep your life easy here the command ssh -N -L 8888:127.0.0.1:80 -i <pem file name> [email protected]. You'll notice I've left the public ip for the Wordpress box. To make a complicated story short if you are running MySql, MariaDB or MongoDB your user name is root. If you are running Postgres the user name is postgres. The password is the same as the one before that we found from the cat bitnami_application_password. Now to actually access the database use the url http://localhost:8888/phpmyadmin/ in your browser with the username and password we discussed above and you'll be into the database like this

From here it's easy to run simple Sql queries for example to see the titles of posts.

USE bitnami_wordpress;  
SELECT post_title FROM wp_posts;  

Easy Stuff

You can see that Lightsail makes running infrastructure services a breeze with almost no effort. Many smaller hosting companies have seen Wordpress installation be their bread and butter in the past. However, I think you'll agree this process is very smooth and empowers you with control.