How I Automated Infrastructure With Iac Using Terraform

How I Automated Infrastructure With Iac Using Terraform

OVERVIEW

In times past, people have been building infrastructures in DevOps manually which hasn't been easy because it takes a lot of time and effort to set up and dismantle infrastructures. Taking a lot of time and effort to build infrastructures will also reduce the production rates and that will be a setback in DevOps practices generally.

So in this article, I will be taking you through the steps of automating infrastructures using terraform.

TOOLS USED

  1. Windows terminal
  2. Terraform
  3. Packer
  4. Ansible

WHAT IS TERRAFORM

Hashicorp Terraform is an IaC tool used to handle the automation of cloud and on-premise resources by using specific code written in terraform language. Terraform works by using cloud resource providers' APIs to create and manage resources.

QUICKSTART

. I created a terraform cloud account, created an organization in the account and I configured my workspace.

pro13.PNG

. I created a repository in my Github account and named it terraform-cloud. Then, I committed and pushed my terraform codes into the repository.

. Since I'm creating AWS(Amazon web services) infrastructures, I configured the variables on my terraform-cloud account and I inserted my "AWS_ACCESS_KEY_ID" and my "AWS_SECRET_ACCESS_KEY"

pro14.PNG

. I used PACKER to create images in my AWS console

pro5.PNG

pro15.PNG

. I used Ansible to configure the infrastructure

pro48.PNG

. Then I ran the terraform scripts in my terraform cloud account using; Terraform plan and Terraform apply

pro19.PNG

pro20.PNG

pro21.PNG

. I checked my AWS console to confirm if everything I specified was created

. After going through all the processes, I used Terraform destroy also to destroy the created infrastructures.

CONCLUSION

Building infrastructures with a lot of stress, time, and effort will only lead to frustration and delay in production. Why not try out an IAC tool like terraform today like I've done and make your DevOps work easier and faster? To learn more about automating infrastructure with IAC, visit %[darey.io]