Amazon Lightsail: Virtual Cloud Server
Take an in-depth at topics relating to Amazon Lightsail, such as virtual private server basics, getting started with Lightsail, and Lightsail container service.
Join the DZone community and get the full member experience.
Join For FreeAmazon Lightsail, launched in 2016, is essentially a virtual private server (VPS) that offers you everything needed to deploy an application or website in a cost-effective and easy-to-understand manner. It is a basic service, but extremely convenient.
It is designed for customers, developers, small businesses, or startups to get quickly started in AWS. It reduces the learning curve in the beginning, and users can later adopt the broad AWS Services as they get more familiar with the AWS cloud and/or solution workload increases.
Under the hood, Lightsail is powered by Amazon EC2, Application Load Balancer (ALB), and other AWS services. By doing this, it offers the level of security, reliability, and scalability you are expecting from AWS.
It also works great with container workloads. You can deploy your container images to the cloud with the same simplicity and the same bundled pricing Amazon Lightsail provides for your virtual servers.
In this post, we will cover the following topics:
- Virtual private server basics
- Getting started with Lightsail
- Lightsail container service
Virtual Private Server Basics
Amazon Lightsail is a powerful virtual private server (VPS) built for reliability and performance.
AWS Lightsail is Amazon’s answer to the rise of Digital Ocean, OVH, Linode LLC, and other affordable VPS players in a very lucrative VPS market. Lightsail started as a pretty basic service, but over the years, AWS added features like block storage, Windows support, databases, and containers. Given the history, you can expect some more additions by the time you read this post.
A virtual private server (VPS) is a hosting solution relying on virtualization technology to provide dedicated resources on a server with various users.
A VPS divides real dedicated servers into numerous virtual machines or servers, each with its own hardware, operating system, and applications. VPS hosting is a shared hosting service in which each client has their own virtual machine," but they function and store data in complete isolation.
"Because a virtual computer isolates us from other users, a VPS provides far more freedom and flexibility than shared hosting."
-excerpts from "Can You Use a VPS for Gaming?"
The article "What is a VPS (Virtual Private Server)?" states: "As a result, a VPS is also sometimes referred to as a virtual dedicated server (VDS).
VPS offers several benefits, including high reliability, scalability, better privacy, root access to servers, and manageable monthly costs. As a result, it has extensive applications in transportation, healthcare, hospitality, e-commerce, telecommunication, and banking and financial services worldwide.
Getting Started With Lightsail
In this demo, we will set up a WordPress website using Lightsail. This will help us to see how simple it is to run web applications using Lightsail by selecting some options on a simple webpage.
Later in the post, we’ll also cover the Lightsail container service and will see a simple example of running a Docker-containerized .NET Core Web Application using Lightsail containers.
Let's get started.
You can access the Lightsail dashboard from AWS Management Console and can get started immediately by clicking the Create Instance button:
This will start a very simple one-page Wizard where you can select a few basic configurations such as instance location, instance image, and a few other options.
For example, the following screenshot shows the option selected for location and instance image:
Next, we can select which blueprint to use. You can see a few popular options available on the following screen:
Now, if you don’t see your favorite application there, don’t worry. Lightsail is a server at the end of the day, and you have root access to it; so this shall not be a limiting factor.
For example, if needed, you can add SSH to the instance, install necessary packages, and easily run the .NET Core Web API application. You can also easily configure an NGINX reverse proxy in front of it, and so on. Also, running Docker containers in Lightsail is supported, and you can imagine the possibilities. More on this later.
Back to our instance configuration: In the next section, we have some options available to add a launch script to automate some initial setup, SSH keys, and snapshots:
To keep things simple, we will not make any changes in the Optional section for this demo.
Next, we can choose an instance plan as per our requirement. As you can see, it is very easy to understand the cost and associated capacity:
Next, we can name the instance and add some tags for management purposes. Once this is finished, click the Create instance button, as shown below:
A couple of minutes later, the Lightsail dashboard shows that our instance is running:
If we now visit the public IP address of our instance, our WordPress website is up and running and accessible from anywhere on the internet:
It was a very simple process to get started with AWS Lightsail. We selected a few options on a simple webpage and were able to set up a running WordPress website in a couple of minutes. This simplicity along with options to scale is what makes the Lightsail service an ideal solution for developers, medium-sized businesses, startups, and similar use cases.
Exploring Lightsail Instance
You can perform various instance management actions from the dashboard as shown below:
Furthermore, you can find more information and various controls about your instance by clicking the instance card on the Lightsail dashboard:
You can stop, reboot, or connect to your instance using SSH. Add additional storage, see various metrics graphs, networking, and other options. Go ahead and check out the various options and configurations.
You can delete instances once the instance is no longer needed. Otherwise, it will cost you for the time it is running.
Lightsail Container Service
Starting November 2020, Amazon Lightsail offers a simple way for developers to deploy their containers to the cloud. All we need to provide is a Docker image for our containers, and Lightsail automatically containerizes it for us.
You can check the AWS official website for step-by-step instructions on running containers using Lightsail.
Lightsail container services plugin makes it very easy to create your Lightsail container services, and create deployments using container images from an online public registry, such as Amazon ECR Public Gallery.
The processing of creating a Lightsail container service is very similar to the server. It's a one-page simple wizard to set up. I will not go into the details of this process, as this is well defined in the above-mentioned links. The following screenshot shows a container service created in the Lightsail dashboard:
You can check more details by clicking the card:
As you can see, you can deploy containers from a public registry or directly from your development machine.
I have a very simple .NET Core Web API application with the following Docker file:
You can access the source code on this Git repo. Also, I am using the .NET Core Web API application for the demo, but you can instead use Node.js or a Java-based application, and the principles will be the same.
I simply built the Docker image using Docker CLI on my machine, and used the following command to push it to the Lightsail container service:
aws lightsail push-container-image --region eu-central-1 --service-name container-service-1 --label dotnettokengen --image dotnettokengen
We can see the stored images on the Lightsail dashboard as shown below:
We use images to create deployments as shown in the screenshot below:
Once deployed, we can access the application via its public domain. The following screenshot shows the API call to the .NET Core Web API Controller:
This was a very basic demo of the container functionality available in Lightsail. Please check the official website for more details.
Summary
Amazon Lightsail is a Virtual Private Server. It is a flat-rate, low-cost computing solution with easy setup and low maintenance. It is a scaled-down version of EC2 which is ideal for developers, enthusiasts, and small teams.
It offers various options to start with, such as bare metal Ubuntu servers, or you can create servers from one of the base images and applications bundled with an OS so you don’t have to install them manually.
Lightsail includes a number of sub-services to help create simple architectures. There is a lot offered by Lightsail that we haven’t covered yet in this introductory post, such as supporting snapshots, which are “points in time” copies of the entire instance. You can spin up multiple instances using these snapshots, and place a load balancer in front of those instances for better availability and scalability purposes.
You can create and connect databases easily with Lightsail. VPC peering is another option supported by Lightsail to extend networking reach and it also integrates well with the AWS Route53 DNS service. Static IPs are supported, and Lightsail can also integrate with CDN to speed up content distributions.
Let me know if you have some questions or comments. Until next time, happy coding.
Opinions expressed by DZone contributors are their own.
Comments