Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 1, 2022 02:21 pm GMT

Application Deployment in Amazon Lightsail Instance using AWS CodePipeline and AWS CodeDeploy

Challenges faced to find the solution of how to deploy an application with continuous change in code. I have found the solution in AWS as a service used for automation as AWS CodePipeline. Using CodePipeline service, I am able to set an automation with a github account for continuous integration and continuous delivery. Also able to deploy it using AWS CodeDeploy service. I have used an Amazon lightsail instance to deploy my application with required permissions. In terms of cost and security perspective, an automation set is cheaper as compared to using any other service. Also it is secured and can be notified easily to users.

Amazon Lightsail is a cloud service offered by Amazon Web Services (AWS) that bundles cloud compute power and memory for new or less experienced cloud users. AWS packages memory, processing, storage and transfer into virtual machines (VMs) for customers to purchase, then releases that compute capacity as Amazon Elastic Compute Cloud (EC2) instance. Amazon Lightsail derives its compute power from an EC2 instance. Amazon EC2 is a web service that provides secure, configurable compute capacity in the cloud.

Amazon Lightsail provides easy-to-use cloud resources to get your web application or websites up and running in just a few clicks. Lightsail offers simplified services such as instances, containers, databases, storage, and more. With Lightsail, you can easily spin up websites or applications using pre-configured blueprints like WordPress, Prestashop, or LAMP. You can use Lightsail features to simply host static content, connect your content to an audience around the globe, or get your Windows Business server up and running. The Lightsail console guides you through the configuration process, and in many cases, has components already configured.

AWS CodeDeploy is a fully managed deployment service that automates software deployments to a variety of compute services such as Amazon EC2, AWS Fargate, AWS Lambda, and your on-premises servers. AWS CodeDeploy makes it easier for you to rapidly release new features, helps you avoid downtime during application deployment, and handles the complexity of updating your applications. You can use AWS CodeDeploy to automate software deployments, eliminating the need for error-prone manual operations. The service scales to match your deployment needs.

AWS CodePipeline is a continuous delivery service you can use to model, visualize, and automate the steps required to release your software. You can quickly model and configure the different stages of a software release process. CodePipeline automates the steps required to release your software changes continuously.

In this post, you will get to know how to deploy an application in lightsail instance using codepipeline and codedeploy. Here I have used a lightsail instance to deploy an application. And used codedeploy and codepipeline for automation purposes. Also having metrics to get a record of parameters value in cloudwatch.

Prerequisites

Youll need a Github account and git installed on a local machine. Youll need AWS CLI installed and configured on your local machine.

Youll need an Amazon Simple Storage Service for this post. Getting started with Amazon Simple Storage Service provides instructions on how to create a bucket in simple storage service. For this blog, I assume that I have created a s3 bucket.

Architecture Overview

Image description
The architecture diagram shows the overall deployment architecture with data flow, lightsail server, codedeploy, codepipeline, s3 bucket and github account.

Solution overview

The blog post consists of the following phases:

  1. Create IAM User with appropriate access and Create a Lightsail Instance
  2. Register the Lightsail Instance with CodeDeploy and Configure of application in CodeDeploy
  3. Create CodePipeline and Check the pipeline status after configuration
  4. Testing and Updating the application and Monitoring the metrics in cloudwatchI have a s3 bucket created as below Image description

Phase 1: Create IAM User with appropriate access and Create a Lightsail Instance

  1. Open the IAM console, create a role with policy as codedeploy. Also create a user with programmatic access with s3codedeploybucket policy. Image descriptionImage descriptionImage descriptionImage description
  2. Open the lightsail console, create an instance with linux platform and os only option. Choose the instance plan and define the script for installation of codedeploy agent. Then give the key-value tag and click on create instance. Once the instance is created, we can see all the configuration of the instance and can check if the codedeploy agent service is running.Image descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage description

Phase 2: Register the Lightsail Instance with CodeDeploy and Configure of application in CodeDeploy

  1. Run the commands on the local machine to register and tag your lightsail instance with Codedeploy. Also run a command to verify the machine was successfully registered.Image description
  2. Create an application named DemoDeployApp with EC2/On-premises compute platform. Also create a deployment group with required parameters named DemoDeploymentGroup.Image descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage description

Phase 3: Create CodePipeline and Check the pipeline status after configuration

  1. Create a codepipeline named DemoPipeline. Set up source provider as github and deploy provider as codedeploy. Image descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage descriptionImage description

Phase 4: Testing and Updating the application and Monitoring the metrics in cloudwatch

Image description
Image description
Image description
Image description
Image description
Image description
Image description
Image description
Image description
Image description
Image description
Image description
Image description
Image description
Image description
Image description
Image description
Image description

Clean-up

Delete AWS CodePipeline, AWS CodeDeploy, IAM, Amazon Lightsail Instance, S3 bucket.

Pricing

I review the pricing and estimated cost of this example.
Cost of Lightsail
USD 0.0 per GB for data transfer out = 0.000228 GB = $0.0
USD 0.0 per Hour of 0.5GB bundle Instance free trial = 8.008 Hrs = $0.0
Total = ($0.0+$0.0) =$0.0
Cost of CodeDeploy = $0.02 per on-premises instance update = 3.000 OnPremUpdates = $0.06
Cost of CodePipeline = $0.00 per trial pipeline = 2.000 pipelines = $0.0
Cost of Simple Storage Service = $0.04
Cost of Cloudwatch = $0.0
Cost of Data Transfer = $0.0
Total Cost = $(0.0+0.06+0.0+0.04+0.0+0.0) = $0.1

Summary

In this post, I showed how to deploy an application in Amazon Lightsail instance using AWS CodeDeploy and AWS CodePipeline.

For more details on Amazon LightSail, Checkout Get started Amazon LightSail, open the Amazon Lightsail console. To learn more, read the Amazon Lightsail documentation. For more details on AWS CodeDeploy, Checkout Get started AWS CodeDeploy, open the AWS CodeDeploy console. To learn more, read the AWS CodeDeploy documentation. For more details on AWS CodePipeline, Checkout Get started AWS CodePipeline, open the AWS CodePipeline console. To learn more, read the AWS CodePipeline documentation.

Thanks for reading!

Connect with me: Linkedin
Image description


Original Link: https://dev.to/aws-builders/application-deployment-in-amazon-lightsail-instance-using-aws-codepipeline-and-aws-codedeploy-5ae7

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To