Reader small image

You're reading from  Mobile DevOps

Product typeBook
Published inMar 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781788296243
Edition1st Edition
Languages
Concepts
Right arrow
Authors (2):
Rohin Tak
Rohin Tak
author image
Rohin Tak

Rohin Tak is a mobile and web development enthusiast with expertise in and several years of experience of .NET technologies. Professionally, Rohin has worked for IBM and OnMobile Global as a .NET developer and Xamarin developer respectively. Rohin is now working as a senior software engineer at LeadSquared, one of the fastest growing sales and marketing automation solutions in India. In his spare time, Rohin is mostly found trekking in the Himalayas and exploring new places around the globe.
Read more about Rohin Tak

Jhalak Modi
Jhalak Modi
author image
Jhalak Modi

Jhalak Modi is a DevOps engineer with a deep interest and expertise in implementing large-scale cloud, big data, CI/CD, and automation solutions on a variety of public/private/hybrid clouds, as well as on-premises. She is an AWS Certified Solutions Architect and DevOps professional with more than 10 certifications in trending technologies. She is also a public speaker at AWS events, universities, meet-ups, and corporate trainings. Currently, working with KOGENTiX, Singapore, she has previously worked with Wipro Technologies and Electromech Corporation.
Read more about Jhalak Modi

View More author details
Right arrow

Deploying Applications on AWS

In this chapter, we will cover how to deploy applications to the cloud and look at the prerequisites to do so. Before going forward, we need to understand why we want to deploy applications to the cloud. We have gone through the differences of Cloud versus on-premises systems in Chapter 1, Introduction.

So far, we have gone through various DevOps mechanisms, which are where you will start writing your code and pushing it to a code repository (GitHub), as the commands are pretty straightforward (such as git add, git commit, and git push).

Once the new version of the code is available in GitHub, it will be pulled as a new change to the Continuous Integration and Continuous Deployment (CI/CD) pipeline. We have demonstrated two examples in our book of how to deploy a CI/CD pipeline (Teamcity and VSTS). CI will start the process of building different...

Creation of an instance

Now, let's continue with creating an EC2 instance. There are various methods to create EC2 instances in AWS. We will be going through the following:

  • Lightsail
  • EC2 CLI
  • Teraform

Lightsail

Lightsail is a one-click easy service to create instances, and it is very important for testing applications and development environments where you don't want to spend time on spinning and maintaining nodes. Lightsail also supports creating instances with predefined templates for MEAN, LAMP, Node.js, and LEMP (Nginx). Let's see how we can create instances with Lightsail.

The following are the required steps to create instances in Lightsail:

  1. Log in to the AWS console.
  2. Click on Lightsail under the Compute...

Creating an Elastic Load Balancer, launch configuration, and Auto Scaling Groups

In this section, we will see how to create ELB and ASG using AWS CLI.

Elastic Load Balancer

An ELB automatically distributes a load/traffic across multiple instances in a part of different availability zones (AZs). The member instances can be part of single AZ or multiple AZs. An ELB becomes the single point of contact for the DNS and the end users. An ELB also monitors the instance via a health check; if the instance is healthy, then only the requests will be routed to the instance.

As we have already created instances, we will create an ELB using CLI. The command to do so is as follows:

$ aws elb create-load-balancer --load-balancer-name my...

IAM roles

AWS IAM role gives an extra layer of security by managing and rotating the keys themselves. Keys are encrypted credentials known as access key and secret key.

Access key example is as follows:

aws iam create-role --role-name myTestKey --assume-role-policy-document file://myTestKeyPolicy.json --description "Role for testing access from EC2 to S3 and Route 53"

A policy is JSON document consist of permission delegated from one AWS service to another AWS service. The default permission of an IAM role is all deny (by default blocks all the requests to any service until specified explicitly). Sample policy is for creating and managing an EC2 instance, S3 bucket, and Route 53.

Sample policy (save the following text as myTestKeyPolicy.json):

{
"Version": "2012-10-17",
"Statement": [
{
"Action": "ec2:*",
...

Summary

In this chapter, we looked at various methods of creating EC2 instances for our software deployment. Once an instance has been created, push the software jars into your instances. Use the private instance IP, username (ec2-user), and private key (test.pem) to connect to your machine. Once the testing is completed, make sure you terminate the test instances so you don't pay for them.

T2.micro EC2 instance type is free for use for one year for new AWS accounts.

Later on in the chapter, we went through the creation of ELBs and ASGs using AWS CLI.

You can register your ELB DNS name with your domain service provider (for example, Route 53, GoDaddy, and BigRock) to resolve your application.

You can also try putting some workload into your application and see whether Auto Scaling is increasing the number of instances, and then remove the workload to test the termination...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mobile DevOps
Published in: Mar 2018Publisher: PacktISBN-13: 9781788296243
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Rohin Tak

Rohin Tak is a mobile and web development enthusiast with expertise in and several years of experience of .NET technologies. Professionally, Rohin has worked for IBM and OnMobile Global as a .NET developer and Xamarin developer respectively. Rohin is now working as a senior software engineer at LeadSquared, one of the fastest growing sales and marketing automation solutions in India. In his spare time, Rohin is mostly found trekking in the Himalayas and exploring new places around the globe.
Read more about Rohin Tak

author image
Jhalak Modi

Jhalak Modi is a DevOps engineer with a deep interest and expertise in implementing large-scale cloud, big data, CI/CD, and automation solutions on a variety of public/private/hybrid clouds, as well as on-premises. She is an AWS Certified Solutions Architect and DevOps professional with more than 10 certifications in trending technologies. She is also a public speaker at AWS events, universities, meet-ups, and corporate trainings. Currently, working with KOGENTiX, Singapore, she has previously worked with Wipro Technologies and Electromech Corporation.
Read more about Jhalak Modi