An open API service indexing awesome lists of open source software.

https://github.com/liteobject/terraform-tutorial

I am learning Terraform
https://github.com/liteobject/terraform-tutorial

Last synced: 20 days ago
JSON representation

I am learning Terraform

Awesome Lists containing this project

README

          

# Terraform Tutorial

## 1. What is Terraform?
- Imagine code that defines your entire infrastructure - servers, networks, databases, and more. That's Terraform!
- It's a tool for Infrastructure as Code (IaC), automating infrastructure provisioning and management across various cloud providers and on-premises environments.

## 2. How Does Terraform Work?
- Configuration Files: Write declarative configuration files (`.tf`) describing your desired infrastructure state.
- State Management: Terraform keeps track of your infrastructure's actual state in a local `terraform.tfstate` file.
- Planning and Applying: Run `terraform plan` to see what changes will be made based on your configuration and state.
- Execution: Finally, run `terraform apply` to actually create or update resources based on the plan.

## 3. Core Concepts:
- Providers: Modules representing cloud platforms like AWS, Azure, GCP, etc.
- Resources: Building blocks of your infrastructure, like virtual machines, databases, security groups.
- Attributes: Properties of resources, like IP address, username, storage size.
- Modules: Reusable configurations for complex infrastructure components.

## 4. Getting Started:
- Install Terraform: https://developer.hashicorp.com/terraform/install
- Choose a Cloud Provider: AWS, Azure, GCP, etc.
- Write a simple main.tf file:

```terraform
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "my_resource_group" {
name = "my-terraform-rg"
location = "West Europe" // Replace with your desired location
}

...

Explanation:
- Provider Block:
- Specifies `azurerm` as the provider to interact with Azure.
- Includes `features {}` to enable necessary features for Azure.

- Resource Block:
- Defines a resource of type `azurerm_resource_group`.
- Sets the `name` to the desired resource group name.
- Sets the `location` to the preferred Azure region.
```

- Install the AzureRM provider: `terraform init`
- Authenticate with Azure: `az login`
- Run `terraform plan` and review the planned changes.
- If all looks good, run `terraform apply` to provision the server!

## 5.Where to Learn More:
- Official Terraform Documentation: https://developer.hashicorp.com/terraform/docs
- Tutorials and Examples: https://developer.hashicorp.com/tutorials
- Interactive Playground: https://play.sentinelproject.io/