Introduction to AWS Lightsail and Advantages of Simplified Cloud Platforms
Introduction
Amazon Lightsail is a Cloud Platform (PaaS/IaaS) service designed to simplify the deployment of web applications and virtual servers for users. It is an ideal solution for developers, small businesses, or those new to AWS who do not want to deal with the complexity of EC2.
Advantages
- Simple to use: Provides pre-configured blueprints for popular platforms such as WordPress, Node.js, or LAMP stack with just a few clicks.
- Predictable costs: Lightsail uses a flat-rate monthly pricing model, including storage (SSD), bandwidth, and RAM, helping you easily manage your budget.
- Intuitive interface: The Console is streamlined, focusing on core features like Instance, Database, and Networking management.
- Easy to scale: When the application outgrows Lightsail's scale, you can easily export a snapshot to Amazon EC2 to take full advantage of the AWS ecosystem.
- Built-in services: Comes with essential features like DNS management, Static IP, basic Firewall, and Load Balancer.
Prerequisites
In this article, I will deploy an application using React Vite. As in previous articles, you can also use your project if you want to change it. Here, I'm just updating the Nginx config to handle the refresh error when using React Router.
Create a file named nginx.conf with the following content to cache resource files and redirect traffic to the index file when accessing the web application's routes directly:
Update the Dockerfile as follows:
Then, rebuild the Docker image and push it to AWS ECR before continuing with the next section.
Detail
Continue using AWS CDK, create the file lib/lightsail-stack.ts with the following content:
Creating AWS Lightsail is also relatively simple, requiring only the use of lightsail.CfnContainer and providing the following main information:
- power: this is the configuration of the machine you need, including levels like nano, micro, small, medium, large.
- containerServiceDeployment: information about the Docker image and port you want to use.
- publicEndpoint.containerPort is the port for external access.
- healthCheckConfig: health check information. Here, I'm configuring it to consider success if accessing the web application returns a status code between 200-499.
Update the aws-cdk.ts file to use the newly created stack:
Result after deployment:
Happy coding!
Comments
Post a Comment