Thursday, February 21, 2019

stderr: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools

If you get the above error, you need to go ahead and install XCode command-line tools.

The problem is that Xcode Command-line Tools needs to be updated.

xcode-select --install

Monday, February 11, 2019

Build Pipelines in Azure DevOps - How to build pipelines for Java WebApp and migrate to Azure

Building pipelines in Azure DevOps is really easy, you can migrate your application code from any where into Azure using Azure pipelines.


You need to create an account by clicking on below URL:

Once you sign in, you need to create a project.

Create App service on Azure portal
What is App service?

Azure App Service enables you to build and host web apps, mobile back ends, and RESTful APIs in the programming language of your choice without managing infrastructure. It offers auto-scaling and high availability, supports both Windows and Linux, and enables automated deployments from GitHub, Azure DevOps, or any Git repo.

How to create an app service in Azure Portal?

1. Go to Azure portal -

2. Click on Create App services, create app service.

3. Enter WebApp details
Select subscription as free trial.
Resource group as some name
Name should be unique
Publish - Code
Run time stack --> Choose Tomcat 8.5 under Java 8
Operation System as Linux
Region as Central

4. Select App service plan as it is shown
Select sku and size
Choose Dev/Test and select B1 and click apply

Click on Review and Create and click on Create

Now this should have created a WebApp
Now go to App services, Click on WebApp, click on URL and make sure WebApp is up and running.

Steps for creating pipelines in Azure Devops
1. Click on Pipelines, Builds.

2. Click on New pipeline

3. Select source repository - it could be your Bitbucket or Azure Repo and click continue

4. If your application is Java stack, type Java and Choose Azure WebApp for Java

5. Click on pipeline name and re-name per your naming standard

6. Modify maven goal as clean install

7. Click on Stop Azure WebApp step, Enter Azure WebApp details - where  you would like to deploy your app in Azure.

8. Do the same in Deploy Azure WebApp & Start Azure WebApp steps.

9. Now click on Save and Queue.

10. This should kick start build,

Friday, February 8, 2019

How to create EC2 instances using Terraform | Automate EC2 instance Creation using Terraform on AWS Cloud | Terraform With AWS Cloud

Hashicorp's Terraform is an open-source tool for provisioning and managing cloud infrastructure. Terraform can provision resources on any cloud platform. 

Terraform allows you to create infrastructure in configuration files(tf files) that describe the topology of cloud resources. These resources include virtual machines, storage accounts, and networking interfaces.
We will see how you can use Terraform to provision EC2 instance. Please do the below steps for provisioning EC2 instances on AWS:

Watch the steps in YouTube channel:


2. Create a new access key if you don't have one. Make sure you download the keys in your local machine. Login to AWS console, click on username and go to My security credentials.
 Continue on security credentials, click on access keys

Perform below commands in MacOS/EC2 where you have installed Terraform:

First setup your access keys, secret keys and region code locally.
aws configure

cd ~
mkdir project-terraform
cd project-terraform

Create Terraform Files
sudo vi

variable "aws_region" {
       description = "The AWS region to create things in." 
       default     = "us-east-2

variable "key_name" { 
    description = " SSH keys to connect to ec2 instance" 
    default     =  "myJune2021Key

variable "instance_type" { 
    description = "instance type for ec2" 
    default     =  "t2.micro" 

variable "security_group" { 
    description = "Name of security group" 
    default     = "my-jenkins-security-group-2022" 

variable "tag_name" { 
    description = "Tag Name of for Ec2 instance" 
    default     = "my-ec2-instance" 
variable "ami_id" { 
    description = "AMI for Ubuntu Ec2 instance" 
    default     = "ami-0b9064170e32bde34

Now create file

sudo vi

provider "aws" {
  region = var.aws_region

resource "aws_vpc" "main" {
  cidr_block = ""
  instance_tenancy = "default"
  tags = {
    Name = "main"

#Create security group with firewall rules
resource "aws_security_group" "jenkins-sg-2022" {
  name        = var.security_group
  description = "security group for jenkins"

  ingress {
    from_port   = 8080
    to_port     = 8080
    protocol    = "tcp"
    cidr_blocks = [""]

 ingress {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = [""]

 # outbound from Jenkins server
  egress {
    from_port   = 0
    to_port     = 65535
    protocol    = "tcp"
    cidr_blocks = [""]

  tags= {
    Name = var.security_group

resource "aws_instance" "myFirstInstance" {
  ami           = var.ami_id
  key_name = var.key_name
  instance_type = var.instance_type
  vpc_security_group_ids = []
  tags= {
    Name = var.tag_name

Now execute the below command:
terraform init
you should see like below screenshot.

Execute the below command
terraform plan
the above command will show how many resources will be added.
Plan: 3 to add, 0 to change, 0 to destroy.

Execute the below command
terraform apply
Plan: 3 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
Now login to EC2 console, to see the new instances up and running

List Resources created by Terraform
Execute the below command to view list of the resources created by Terraform.
terraform state list
The above command will list three resources created.

You should be able to see EC2 instance up and running in AWS console.

How to push Terraform files into GitHub
All Terraform files should be checked into version control systems such as GitHub, BitBucket or GitLab. Let us see how to push code changes into GitHub. Make sure you are in the directory where Terraform files are created.

Create Remote repo in GitHub
Create a new repo with below name, make sure it is a private repo. Also do not click on initialize this repository with a README option.

 Note down the remote url as highligted below:

If you have any issues in uploading tf files, you may not have created ssh-keys and uploaded into GitHub. Create ssh keys using ssh-keygen command:

This should generate both public and private keys.
Copy the public keys by executing the below command:
sudo cat ~/.ssh/

Initialize the directory first
git init

The above command will create local git repository.
Now add terraform files.
git add *.tf

git commit -m "Added terraform files"

Copy the below red highlighted url from above screenshots circled in red.
git remote add origin your remote repo url per above screenshot

Now push the code into GitHub
git push -u origin master

Now Login to GitHub to view the Terraform files