InfraSketch Tutorial, Part 2

Our journey to help DevOps engineers automate the Terraform template creation process started in 2020. A year later, our product "InfraSketch" is ready for release.

APR 22, 2021 | ABHISHEK HUGAR
undefined

Our journey to help DevOps engineers automate the Terraform template creation process started in 2020. A year later, with a ton of elbow grease, our product, “InfraSketch” is ready for release. This blog will walk you through every component of the product and how a DevOps engineer can use InfraSketch to generate Terraform templates and spin up their infrastructure.

Specifically, this blog reviews use cases for InfraSketch. If you're interested in a more basic tutorial that gives an overview and goes over icons/properties, check out Part 1 of this blog series.

Interested in learning more? Join our Slack, led by DevOps experts, to meet other professionals and learn more about Terraform. We will also have more opportunities to engage closely with InfraSketch in the Slack.

Try InfraSketch for yourself.

Use Cases for InfraSketch

Let’s now consider 2 simple use cases of creating Terraform templates using InfraSketch.

Use Case 1

Creation of 3 servers with Ubuntu-20.04 OS, on AWS provider in the us-west-1 region, with the following configuration:

Server1- 3 instances of a web server with a size specification of “t2.micro” and allowing both inbound and outbound traffic.

Server2- A simple database server of size “t2.micro” and allowing both inbound and outbound traffic.

Server3- A bastion server of size “t2.micro” and allowing both inbound and outbound traffic.

How to Create, Using InfraSketch:

The very first step, in this case, would be to specify the provider and the region. For this, I have selected the “AWS” provider. Then, I drag and drop the “Gateway” and specify the following properties:

Region: us-west-1
VPC Network: 10.0.0.0/16


Next, it’s important for my configuration that I also define the subnet and its properties before I start creating my servers. So, I add a subnet to the configuration with the following properties:

CIDR: 10.0.0.0/24
Availability Zone: us-west-1a

NOTE- If you are selecting the components from the list of icons on the left, do not forget to make the appropriate connections between them by using the arrow icons that appear next to the components when you click on them.

Now that I have my gateway and the subnet, I will first create the “Server1” with the following configurations:

Name: Server1
Size: t2.micro
Count: 3
Operating System Image(AMI): ubuntu-20.04
Elastic: True
Remote Command: I want to ensure that “Docker” is installed, run, and then “nginx” is run on docker. Therefore, I add these remote commands:

sudo apt-get update
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker ubuntu
sudo docker run -d --name web -p 80:80 nginx
Security Rules: I will be allowing incoming traffic from ports 80, 443, and 22-25 with TCP protocol. The outbound traffic will be allowed completely.
Tags: Server Role: Web-server and OS: Ubuntu-20.04
SSH Key Path: ~/.ssh/id_rsa.pub


Similarly, I set up Server2 and Server3.

Now that I have drawn and specified the properties required for my configuration, I will click on export and save the Terraform template on my local machine.

Use Case 2

Creation of a load balancer and server with Ubuntu-20.04 OS, on AWS provider in the us-west-1 region, with the following configuration:

LB-Server1- 3 instances of a web server with a size specification of “t2.micro” and allowing inbound traffic.

How to Create, Using InfraSketch:

The first step of selecting the cloud service provider and configuring the properties of “Gateway” remains the same as in “Use Case 1”:


I will now add a load balancer to the configuration with the following properties:

Name: load_balancer-0
Listeners: 80: 8000
Health: The load balancer port whose health needs to be checked will be “8000” in this case with a path value of”/” and the “HTTP” protocol.

The next step will be to define the network or subnet properties for the server that I create next.


Finally, as required I will setup the server required with the following properties:

Name: LB-Server1
Size: t2.micro
Count: 3
Operating System Image(AMI): ubuntu-20.04
Elastic: True
Remote Command: I want to ensure that “Docker” is installed, run, and then “nginx” is run on docker. Hence, I add these remote commands:

sudo apt-get update
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository 'deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable'
sudo apt-get update
sudo apt install docker-ce -y
sudo usermod -aG docker `whoami`
sudo systemctl start docker
sudo systemctl enable docker
sudo mkdir /opt/html
echo \"<h1>This is a server</h1>\" | sudo tee /opt/html/index.html
sudo docker run -d --name web -v /opt/html:/usr/share/nginx/html -p 8000:80 nginx
Security Rules: I will be allowing only the incoming traffic from ports 8000 and 22 with TCP protocol.
Tags: Server Role: Web-server, load_balancer: web_lb, and OS: Ubuntu-20.04
SSH Key Path: ~/.ssh/id_rsa.pub

I will now click on export to save the “Terraform templates” on my local system.

--

We hope you enjoyed this quick sneak preview into our newest tool, InfraSketch. Looking to discuss more use cases for InfraSketch--or simply looking to find out more? Join our Slack community to connect with other DevOps professionals.

PS: Did you know we have weekly Jam sessions on DevOps topics? The weekly invites go out on our Slack and Twitter channels. We hope to see you there!