The simplicity of working with Terraform for Provisioning Infrastructure.

The simplicity of working with Terraform for Provisioning Infrastructure.

Terraform is one of the most interesting and demanding tools for provisioning infrastructure in a much simpler and reliable way.

Being an opensource tool, it has lots of modules available to support almost all the leading cloud service provider and their API to create resources on their environment.

The first step toward using any tools like Ansible, Terraform, Chef, Packer etc. is, you must be aware of creating a resources manually on the cloud before automating any task so that you will have a better understanding of what you are doing.

Before going forward with Terraform you should consider few of the below points to create reusable Terraform code :-

1) In how many regions you need the Infrastructure resources (us, eu and etc) .
2) Environments you need like Production, Staging, Development.
3) Where you are going to store Terraform State file ( terraform.tfstate )

Terraform (terraform.tfstate) state file contains the information of your Infrastructure resources in “Json” which will get created while running it.

The basics command for running Terrraform are :

You should keep “terraform.tfstate” either on the S3 bucket of AWS or somewhere safe on Github or on hard drive (Github not recommended only for testing as Json may contains your SECRETS ).

For the first time, if you are using Terraform, you need to know that every time you will run the Terraform, it will read the state file and update or append it according to the changes you have done in your code.
You should know that Terraform is idempotent, and it will not create the resources again and again, no matter how many times you are running with the same configuration or code.

The basic structure of creating Terraform Directories are :

1 ) Create Parent Directory ( “terraform-test” ).
2 ) Create Workspace according to your Regions ( terraform-eu
and terraform-us ).
3 ) Now each of your Workspace will contain you
Environments ( staging, production, development ).

So, the complete Directories will look like :

Now Modules is just like a normal Terraform code, the only difference is whatever code going to be common in “terraform-eu” and “terraform-us” will lies in modules, and you just need to call it.

We have three Workspace over here,

1) Default
2) terraform-eu
3) terraform-us

To create workspace you can run the command :

Listing your workspace you can run the command :

To know your current workspace you can run the command :

Switching your current workspace you can run the command :

Deleting your current workspace you can run the command :

So, the above structure will not create any mesh, when your infrastructure will start growing as per your company requirements.

ASKOPS APP IS NOW AVAILABLE ON PLAYSTORE.

Askops
Askops
Developer: Nikhil raj
Price: Free

Leave a Reply