Why work with Terraform?
terraform

Why work with Terraform?

The problem that Terraform was created to solve:

case scenario:

Create a Kubernetes cluster on AWS to run at least 5 microservices

what the above statement really means

  1. Create at least one master node - (EC2 instances) and at least two worker nodes(EC2 instances)
  2. Create two private networks through which nodes can communicate with each other and public networks through which nodes can communicate with the outside world. Create certificates for each node for this case at least 3 certificates
  3. create a gateway for each node.
  4. create tags for each resource you create
  5. ingress and Egress
  6. Make sure that all these resources are created in the same time zone...

you need to keep track and know exactly where you are at because the following is a result of a misstep

  • waking up to find you owe AWS thousands of dollars because you forgot to shut down an EC2 instanc

  • Forgot to create a private network and the cluster is not working
  • Maybe you created more resources than warranted.
  • Maybe it is a test environment where you need to keep track of everything you have created in order to destroy or delete them once you are done
  • And not to be killjoy from the screenshot above in order to create a k8s cluster 54 items are needed to create it successfully

Ooh yeah thats how crazy the whole thing is!

but lucky the Hashicorp guys created Terraform

Terraform is an infrastructure as code (IaC) tool.

so why Terraform?

Terraform defines a desired state: when you have a terraform file you want to apply- if the desired state requires three nodes and only 2 nodes are already created, it will only add one more node.

Basic Workflows:

terraform init        

Initializes the Terraform workspace - creating and keeping track of the state at which it is being created to manage.

terraform plan        

Gives you a highlight and lists everything that will be created from the file configuration

terraform apply        

it creates and updates the state both on its local state and creates resources listed on the plan above

terraform destroy        

it destroys everything created by the apply command.


so from the above screenshot, 54 resources are listed when you run terrraform plan

and 54 are going to be created when you run terraform apply

those resources including creating EC2 instances, subnets, certificates, and tags among others.

and to destroy all you have to do is run terraform destroy

terraform file

I used this to create those 54 resources, it might be outdated but it proves a point of how resourceful Terraform is

I hope your DevOps is easier with Terraform

Nana Janashia Is an amazing teacher when it comes to DevOps, Patrick Odhiambo thanks for the Edit



Patrick Odhiambo

DevOps & Multi-Cloud Engineer | AWS & Azure Specialist | Building Secure, Scalable Infrastructure-as-Code Solutions

11 个月

Well said, terraform is a handy tool and I believe my friend marcrine musimbi would agree, she made me love this IaC tool

要查看或添加评论,请登录

Anthony Miracho的更多文章

社区洞察

其他会员也浏览了