freundcloud

Terraform Configuration

This section covers Terraform configuration across multiple cloud providers. Terraform uses the HashiCorp Configuration Language (HCL) to declaratively describe your infrastructure.

Provider Configuration


# Azure Provider configuration
provider "azurerm" {
  features {}
  subscription_id = "your-subscription-id"
  tenant_id       = "your-tenant-id"
}

# Create a resource group
resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "East US"
  
  tags = {
    environment = "dev"
  }
}

plaintext

For more details on Azure specific configurations, see the Azure section.


# AWS Provider configuration
provider "aws" {
  region = "us-west-2"
}

# Create a VPC
resource "aws_vpc" "example" {
  cidr_block = "10.0.0.0/16"
  
  tags = {
    Name = "example-vpc"
    Environment = "dev"
  }
}

plaintext

For more details on AWS specific configurations, see the AWS section.


# GCP Provider configuration
provider "google" {
  credentials = file("account.json")
  project     = "your-project-id"
  region      = "us-central1"
}

# Create a GCP network
resource "google_compute_network" "example" {
  name                    = "example-network"
  auto_create_subnetworks = false
}

plaintext

For more details on GCP specific configurations, see the GCP section.

Backend Configuration

Your Terraform state can be stored in various backends. Choose the one that best fits your workflow:


terraform {
  backend "azurerm" {
    resource_group_name  = "terraform-state-rg"
    storage_account_name = "terraformstate00123"
    container_name       = "tfstate"
    key                  = "prod.terraform.tfstate"
  }
}

plaintext


terraform {
  backend "s3" {
    bucket = "my-terraform-state"
    key    = "prod/terraform.tfstate"
    region = "us-east-1"
    dynamodb_table = "terraform-locks"
    encrypt = true
  }
}

plaintext


terraform {
  backend "gcs" {
    bucket = "tf-state-prod"
    prefix = "terraform/state"
  }
}

plaintext

Current Terraform Version

This documentation assumes Terraform version 1.10 or higher.