Sunday, March 15, 2020

Terraform for Absolute Beginners - Create your first EC2 instance

Objective : Today, I will help you to create your EC2 instance using terraform.


Terraform is an Infrastructure as code (IaC) tool made by Hashicorp for building, changing and versioning of infrastructures. Now a days the demand of Terraform is getting higher. Terraform can be used with the popular cloud providers like AWS, Azure, Google, Oracle etc.

Pre Request

You need a user in AWS, having necessary permissions to create an EC2 instance.
(Please check our blogs/videos, how to add permission for an AWS user)

Steps to Provision

  1. Download the terraform binary file from
  2. Extract the terraform zip file
  3. The result is a terraform binary file
  4. cp terraform /usr/local/bin/terraform
  5. Validate terraform by using the command terraform -v

Minimal configuration for starting EC2 instance

mkdir terraform-workshop
cd terraform-workshop

provider "aws" {
access_key = "YOUR_ACCESS_KEY"
secret_key = "YOUR_SECRET_KEY"
region = "us-east-1"

resource "aws_instance" "example_ec2" {
ami = "ami-2757f631"
instance_type = "t2.micro"

Save the file. 
You will get your AWS access_key and secret_key as a pre-request.

terraform init
terraform apply

Login to your AWS console and check the EC2 instance under N. Virginia region.

terraform destroy

Will make sure to remove all the AWS resources which we created just above.

Wednesday, February 5, 2020

Error: CERT_UNTRUSTED in npm install

In ubuntu18, when I tired npm install, I am getting the following error


Fix : Remove the current nodejs and npm and install the latest nodejs and npm version.
This will fix the error

Monday, March 18, 2019

How to find files which do not have a string

In Linux, i have a folder which has 1K files. I need to know which all files doesn't have a string which I need. In this example, I need to know which all files doesn't have the string/word - apps

cd /path/to/folder
grep -rIL apps

This will list the files which doesn't have the string "apps" in it 

Thursday, March 14, 2019

CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

Scenario :

My UI is developed in OJet. It accept some input fields from browser and these inputs needs to be passed as a parameter a shell script.

My Ojet application is running on port 80 and I have a nodejs server running on port 8000. From Ojet web UI when a user clicked on button, it will call an api POST request to my nodejs application and the user input fields are as parameters.

How to solve this error

CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Open your nodejs server.js file (In my case) . Add the following res.header fileds.

app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");

It fixed my issue.