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

Simultaneously Deploying Infrastructure across the Globe

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.

---

Companion Code: github.com/ksatirli/deploying-across-the-globe

Kerim Satirli
PRO

December 01, 2022
Tweet

More Decks by Kerim Satirli

Other Decks in Programming

Transcript

  1. re:Invent 2022 Simultaneously Deploying Infrastructure across the Globe.

  2. None
  3. Provision multiple regions without region-specific code.

  4. 01 All Availability Zones, None of the paper-cuts Geography

  5. AWS Regions

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

    resource "aws_instance" "order_processing" { ami = var.ami_ids["orders"] instance_type = "m5.large" !!" }
  7. 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"] } }
  8. 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", ]) }
  9. 02 Global Infrastructure, Local Isolation Workspace Seeding

  10. 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 } }
  11. 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 !!" }
  12. Regional Terraform Cloud Workspaces app.terraform.io/app/ksatirli/workspaces

  13. Regional Terraform Cloud Workspaces app.terraform.io/app/ksatirli/workspaces

  14. Regional Terraform Cloud Workspaces app.terraform.io/app/ksatirli/workspaces

  15. 03 Single Code-base, Regional Impact. Single

  16. Regional Terraform Cloud Workspace app.terraform.io/app/ksatirli/workspaces/aws-ap-northeast-1

  17. Regional Terraform Cloud Workspace app.terraform.io/app/ksatirli/workspaces/aws-ap-northeast-1

  18. Regional Terraform Cloud Workspace app.terraform.io/app/ksatirli/workspaces/aws-ap-northeast-1

  19. Regional Terraform Cloud Workspace app.terraform.io/app/ksatirli/workspaces/aws-ap-northeast-1

  20. Regional Terraform Cloud Workspace app.terraform.io/app/ksatirli/workspaces/aws-ap-northeast-1

  21. Regional Terraform Cloud Workspace aws-ap-northeast-1-ueco.s3.amazonaws.com/index.html

  22. Sr. Developer Advocate II at HashiCorp he / him @ksatirli

    Kerim Satirli
  23. Thank You