Terraform with AWS…
Welcome,today we will be discussing about terraform,one of the most powerful System provisioning management tool.
There are three main ways to cloud compute which are:
a) IaaS — Infrastructure as a service eg AWS, Azure.
b) PaaS — Platform as a service eg App-engine, Azure
c) SaaS — Software as a Service eg Gmail, GDrive, Dropbox
Cloud automation is a hot topic in the technology industry and managing it properly is a big responsibility.Any loophole given can be dangerous for the organization.
Infrastructure as a code(IaC) is a process of managing and provisioning and implementing services like databases in the cloud with the help of readable files.It plays a vital role when suppose you have to launch 1000 instances.So,definitely you will not do that by launching one instance at a time.So you will need an IaaC tool to do this for you.So you write a configuration file and then run it where you can launch instances as per your requirements.
Now,Suppose you have to launch 2 EC-2 instances ,VPN and a s3 bucket on AWS.Let's look about some commands which will help in implementing the above scenario :-
Firstly let’s see how the script will look like-
1. Terraform init :-
This command performs several initialization steps in order to prepare a directory for use.It assumes that the working directory contains a configuration and will attempt to initialize that configuration.After successfully writing the script, if we perform “terraform init” we can start working on terraform.
2. Terraform plan :-
The “terraform plan” refers to the application requirements.The terraform plan command is used to create an execution plan.It configures and instantiates resources and their dependencies.
3. Terraform apply :-
The terraform apply command is used to apply the changes required to reach the desired state of the configuration generated by a terraform plan execution plan.
4. Terraform destroy:-
The terraform destroy command is used to destroy the infrastructure managed by terraform.This command terminates resources defined in the terraform configuration.
If -auto-approve is written,then the destroy confirmation will not be there.
5.Terraform validate :-
The terraform validate command validates the configuration files in a directory, referring only to the configuration and not accessing any remote services such as remote state, provider APIs.Validation includes a basic check of syntax as well as checking that all variables declared in the configuration.
Now let’s verify whether the resources are created or not.
Thanks for reading :)