Terraform is an open-source tool developed by Hashicorp, which can create infrastructure in almost all virtual environments.
ARM Templates - Can create infrastructure in Azure.
Cloudformation can create infrastructure in AWS.
16thmar
Let's log in to the AWS Console account and start creating an EC2 Instance,
step by step as shown below.
let's select the Linux machine and it should be free tier t2.micro and the configurations as shown below.
select launch keypair/ create a new keypair (.pem) file
select the keypair & click on launch instance.
Now copy the Public IP to connect to the machine.
To connect to that machine use the SSH command, open the PowerShell terminal run ssh -i, and copy the path of that PEM file and public IP as shown below and run it will automatically connect to that machine.
go to Terraform's official website and select the OS to install Terraform
Create a Linux VM and SSH into it and execute the steps based on your distribution.
Select the VM you need to install and copy the commands provided
paste the command for execution.
after running the command, we check whether the terraform is installed or not by the command 'terraform --version'
Only Terraform doesn't have any intelligence, terraform providers speak with the particular cloud we choose.
There are three ways to speak with cloud
speaking via the website: (log in to the website create a machine & it is UI-based access)
Command line access: (you can access with AWS by some commands
The third access is by writing code: it will communicate via provider with the selected cloud.
provider gives some intelligence of AWS to terraform.
once we configure Terraform, the Terraform speaks with the provider and the provider speaks with the AWS.
In the case of AWS, Provider needs some credentials ie Access key & Secret key.
when you give the access key and secret key terraform comes to know which account to speak about.
Terraform provider uses SDK to speak with AWS it doesn't use CLI, because terraform provider is a code which is written in go language which speaks with AWS using its API
We just need to know about the resources
we need to create an access key and secret key in AWS,
we need to create a template in that template we need to configure the provider.
when we are configuring the provider we need to pass the access key and secret key.
Terraform AWS Provider uses the AWS APIs to get the infra created.
To create infrastructure in your AWS account, it needs AWS Programmatic credentials ie an Access key, and a secret key.
when you configure these access keys and secret keys, aws terraform tells you that there are multiple ways of doing it.
create IAM secret key and access key
now need to configure the terraform provider