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

Simultaneously Deploying Infrastructure across ...

Simultaneously Deploying Infrastructure across the Globe

In this demo, I show how to deploy a single code-base across all available AWS Regions using HashiCorp Terraform Cloud and the AWS and AWSCC Providers for Terraform.

Avatar for Kerim Satirli

Kerim Satirli

December 01, 2022
Tweet

Resources

More Decks by Kerim Satirli

Other Decks in Technology

Transcript

  1. Terraform Concepts CODE EDITOR # EC2 Instance for order processing

    resource "aws_instance" "order_processing" { ami = var.ami_ids["orders"] instance_type = "m5.large" !!" }
  2. Terraform Concepts CODE EDITOR # get list of all opted-in

    AWS Regions data "aws_regions" "available" { all_regions = true filter { name = "opt-in-status" values = ["opted-in"] } }
  3. Terraform Concepts TERMINAL ~ >_ echo "data.aws_regions.available" | terraform console

    { "all_regions" = tobool(null) "filter" = toset([]) "id" = "aws" "names" = toset([ "eu-central-1", "eu-central-2", "us-east-1", "us-east-2", "us-west-1", "us-west-2", ]) }
  4. Terraform Cloud Workspaces CODE EDITOR # create a Terraform Cloud

    Workspace for each AWS Region resource "tfe_workspace" "regions" { for_each = toset(data.aws_regions.available.names) name = each.key description = "Regional Workspace for `${each.key}`." tag_names = [ "regional", ] vcs_repo { identifier = "ksatirli/regional-deployment-example" branch = "main" oauth_token_id = data.tfe_oauth_client.client.oauth_token_id } }
  5. Terraform Cloud Workspaces CODE EDITOR # create a Terraform Cloud

    Workspace for each AWS Region resource "tfe_workspace" "regions" { for_each = toset(data.aws_regions.available.names) !!" terraform_version = var.terraform_version !!" }