Sunday, March 9, 2025

Terraform - Part 1


Terraform Installation

yum install -y yum-utils shadow-utils
yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
yum -y install terraform
terraform version
terram -help
terraform -help plan

Create AWS user for the terraform setup

Create a user in AWS:

1) Login into Aws console

2) Navigate into IAM

 

3) Click on create user button



4) Set a permission of new user

 


5) Click on created user and we can able to see the option for create a key for that specific user.

 



6) It will prompt the use case of your requirement.

 


7) Choose the Command Line Interface option 

8) Take a note of Access Key and secret access key. We need to define these parameter inside of Terraform while automate the infrastructure.

Terraform Architecture:

* Terraform follows a declarative approach to infrastructure management which mention a desire state of your infrastructure through configuration files. It takes care of provisioning and configuration of resources to achieve that state.



Terraform has consist of four components.
* Providers
* Modules
* Resources
* Templates
Providers:
It is an essential plugins that provide a interaction between Terraform and remote machines such as Azure, AWS, GCP, VMware and local environments. Terraform uses to providers to provision of resources such as virtual networks and compute instances. We cannot able to create or manage a resources if we are not include the providers in our script.
We need to declare a provider as your root module so that it will inherit with child modules where we can define our desire state of our infrastructure.
Modules:
Module is a collection of template files that resides on a single directory. Module is considered a child module of the template. Modules can be present in local or remote location. Terraform is supporting multiple resources such as Terraform Registry, version control systems, HTTP URLs and private module registries in Terraform.
Resources:
Terraform uses resources blocks to manage various kinds of infrastructure such as virtual networks, compute instances and DNS records. The resource blocks map to one or more infrastructure objects within your Terraform configuration.
Templates:
Terraform template is a collection of files that define the desired state of your infrastructure to be maintained. 







No comments:

Post a Comment