Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Deploying at Scale with HashiCorp Terraform

Deploying at Scale with HashiCorp Terraform

In this talk, I look at how HashiCorp Terraform and HCP Terraform can help deploy at global scale, all from the comfort of a single operational workflow.

This version of the talk was given at the AWS User Group in Las Vegas in August 2024.

Kerim Satirli

August 28, 2024
Tweet

More Decks by Kerim Satirli

Other Decks in Programming

Transcript

  1. HashiCorp Terraform Deploying at Scale Agenda Next Steps 2 3

    Traditional and Modern IT Infrastructure 1 4
  2. Slow Deployments of hardware and software based around manual processes

    Error-prone Mistakes during deployment executions lead to larger problems Hard to control Complicated processes needed to control complicated processes Traditional IT Infrastructure
  3. Fast Deployments of hardware and software based around automated processes

    Secure Deployments are scripted, minimizing errors and enabling validation Scaleable One or all available regions or continents, multiple accounts, multiple clouds. Modern IT Infrastructure
  4. Documented code is readable for both human operators and machines

    alike Versioned code is plain-text and can easily be version- controlled with any VCS Verified code can easily be verified against org-specific deployment rules IT Infrastructure as Code
  5. main executable; interface between user, HCL, CLI operations, and providers

    Terraform Translates HCL definitions into API calls and manages service- specific resources Provider Combines IT Infrastructure definitions into (reusable) building blocks Module Terraform Concepts
  6. ca. 400 Providers built by HashiCorp and HashiCorp Technology partners

    Azure, Splunk, VMware vSphere, etc. ca. 4050 Provider built by the community Pingdom, Sentry, Unifi, etc. Terraform Landscape - Provider
  7. ca. 140 Modules built by Technology Partners ca. 17500 Terraform

    Landscape - Modules Modules built by the community
  8. Handles Create, Read, Update, Delete operations of a resource Resource

    Handles Read operations of a resource Data Source Manages resource and data source configuration State Terraform Concepts
  9. Terraform Code resource "server" "factory" { count = 10 image

    = "rhel-8.1" type = "large" has_public_ip = true region = "eu-west-2" }
  10. Terraform Code resource "server" "factory" { count = 10 name

    = "factory-${count.index}" image = var.image type = var.type has_public_ip = true region = "eu-west-2" }
  11. Multi-Region Deployment aws_regions = toset([ "af-south-1", "ap-east-1", "ap-northeast-1", "ap-northeast-2", "ap-northeast-3",

    "ap-south-1", "ap-southeast-1", "ap-southeast-2", "ap-southeast-3", "ca-central-1", "eu-central-1", "eu-north-1", "eu-south-1", "eu-south-2", "eu-west-1", "eu-west-2", "eu-west-3", "me-south-1", "sa-east-1", "us-east-1", Multi-Region Deployment
  12. Multi-Regional Workspaces module "regional_aws_workspaces" { for_each = toset(data.aws_regions.main.names) source =

    "ksatirli/regional-workspace/tfe" version = "1.2.0" region = { category = "terraform" identifier = each.key prefix = "aws" variable = "aws_region" } vcs_repo = { identifier = "workloads/regional-aws-deployment" branch = "main" } }
  13. Multi-Region Deployment # look up Service Code for EC2 instances

    data "aws_servicequotas_service" "ec2" { provider = "aws.us-east-1" service_name = "Amazon Elastic Compute Cloud (Amazon EC2)" } # update Service Quota for M5 EC2 instances resource "aws_servicequotas_service_quota" "ec2" { provider = "aws.us-east-1" # allow up to 100 M5 instances quota_code = "L-8B7BF662" service_code = data.aws_servicequotas_service.ec2.service_code value = 100 }