Overview
With Terraform
Terraform is distributed under the Business Source License
Key advantages
- Automation: Terraform enables you to quickly and easily create, update, and delete cloud resources for streamlined infrastructure management.
- Code reuse: Terraform supports modules reusable across different projects. This reduces development and testing time.
- Security: Terraform provides version control and audit of infrastructure changes through state snapshots. This helps to prevent unauthorized changes and ensures data security.
How Terraform works
Terraform follows a declarative approach to infrastructure management (Infrastructure as Code
To use Terraform, install it on your computer, configure the provider, and create configuration files (*.tf) describing your infrastructure in HashiCorp Configuration Language (HCL)
Usage example
Let's assume you want to create a VM in Yandex Cloud. The following code describes the configuration of a terraform1 VM with 2 cores and 2 GB of RAM, a boot disk named boot-disk-1, network interface connected to subnet-1, public IP address, and SSH key from a file located at the specified path:
resource "yandex_compute_instance" "vm-1" {
name = "terraform1"
resources {
cores = 2
memory = 2
}
boot_disk {
disk_id = yandex_compute_disk.boot-disk-1.id
}
network_interface {
subnet_id = yandex_vpc_subnet.subnet-1.id
nat = true
}
metadata = {
ssh-keys = "ubuntu:${file("~/.ssh/id_ed25519.pub")}"
}
}
This is just a simple example of how you can use Terraform. With this tool, you can create complex infrastructures with multiple resources and dependencies, provide metadata, manage resources using service accounts, and more.