DEV Community

GargeeBhatnagar for AWS Community Builders

Posted on • Updated on

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.

A keyword define "Devtron" play an important role in sorting the complexity of DevOps, AppOps and Kubernetes. Also "GitHub" helps to integrate and automate. Both Devtron and GitHub is an open source one.

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

You’ll need a Github account and git installed on a local machine. You’ll need AWS CLI installed and configured on your local machine.

You’ll 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 cloudwatch I 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 description Image description Image description Image 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 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

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 description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image description Image 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 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

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.

For more details on Devtron and GitHub, Checkout Links:
Devtron Website
GitHub Repo
Join the Discord Community
Follow on Twitter
Raise feature requests, suggest enhancements, report bugs
Read Devtron Blog

Lets quickly adopt and try it! And post the response using #AdoptK8sWithDevtron #devtron

The above blog is submitted as part of 'Devtron Blogathon 2022' - https://devtron.ai/
Check out Devtron's GitHub repo - https://github.com/devtron-labs/devtron/ and give a ⭐ to show your love & support.
Follow Devtron on LinkedIn - https://www.linkedin.com/company/devtron-labs/ and Twitter - https://twitter.com/DevtronL/, to keep yourself updated on this Open Source project.

Thanks for reading!

Connect with me: Linkedin
Image description

Top comments (1)

Collapse
 
harishchandch24 profile image
harishchandch24@gmail.com

Hi pls help me thanks my whatsapp number contact with me ok +919938135588