What steps are involved in deploying a new resource or object into the infrastructure using Terraform?
sobes.tech AI
Answer from AI
The process of deploying a new resource or object into infrastructure using Terraform typically involves the following steps:
-
Defining the resource in the configuration — a new resource with the necessary parameters is described in a
.tffile. -
Initializing Terraform — the command
terraform initdownloads the required providers and modules. -
Checking the plan of changes —
terraform planshows what changes will be made to the infrastructure. -
Applying the changes —
terraform applycreates or modifies resources according to the configuration. -
Checking the state — Terraform updates the state file reflecting the current infrastructure.
Example of adding a new AWS EC2 resource:
resource "aws_instance" "example" {
ami = "ami-0c55b159cbfafe1f0"
instance_type = "t2.micro"
}
After adding this block, run terraform init, then terraform plan, and terraform apply.