Lesson 3 of 3 Infrastructure as Code with Terraform

Multi-Cloud, Hybrid Cloud and Service-Agnostic Workflows

Terraform manages many platforms with one language and one workflow. This lesson explains what that means for multi-cloud and hybrid cloud deployments and for services beyond cloud computing.

Learning outcomes

After completing this lesson, you will be able to:

  • Explain how Terraform manages several platforms with one workflow.
  • Distinguish a common workflow from portable resource definitions.
  • Describe how Terraform supports hybrid cloud and non-cloud services.

One workflow across platforms

Every cloud platform has its own native IaC tool: AWS CloudFormation, Azure Resource Manager and Bicep, and Google Cloud's Infrastructure Manager. Each manages only its own platform, with its own syntax and state model. Terraform uses the same HCL language, the same init, plan and apply commands, and the same state and module concepts for every platform. Support for a platform comes from its provider.

This is what HashiCorp means by a service-agnostic workflow. The Terraform Registry lists thousands of providers: clouds, Kubernetes and Helm, DNS and content delivery networks, monitoring and incident tools, identity platforms, version control systems and databases. A team can manage a GitHub repository, its branch protection, the cloud resources the application runs on and the monitoring alerts for it in one workflow.

The following diagram shows one workflow across three platforms.

One Terraform workflow across three platforms. For example, a web tier on AWS, analytics on Google Cloud and legacy applications on vSphere are each a provider in the same configuration language. A cross-platform change becomes one pull request whose plan shows the changes on both platforms, applied in dependency order. Resources stay platform-specific.
The platforms are examples.
Sort into groups

Terraform or a native tool?

Exam skills 1.3.1 · 1.3.3

Decide whether each statement describes Terraform or a cloud platform's own IaC tool.

Log in to try this activity Interactive activities are free with an account.

Multi-cloud deployments

A multi-cloud deployment uses two or more cloud providers, for example to meet regulatory requirements, to use a service only one provider offers or to reduce dependence on one vendor. In Terraform, one configuration can require several providers, and resources from different providers can reference each other. The following configuration creates a storage bucket in Google Cloud and a DNS record in AWS that points at it.

terraform {
  required_providers {
    aws    = { source = "hashicorp/aws", version = "~> 6.0" }
    google = { source = "hashicorp/google", version = "~> 8.0" }
  }
}

resource "google_storage_bucket" "assets" {
  name     = "acme-static-assets"
  location = "EU"
}

resource "aws_route53_record" "assets" {
  zone_id = var.zone_id
  name    = "assets.example.com"
  type    = "CNAME"
  ttl     = 300
  records = ["c.storage.googleapis.com"]
}

Terraform builds one graph across both providers and plans them together. What Terraform does not do is make a resource portable: google_storage_bucket describes a Google Cloud bucket, and moving to another cloud means writing that cloud's resource type. The workflow is common; the resource definitions are platform-specific.

Common workflow, not portable resources

Terraform does not translate a configuration written for one cloud so that it runs on another. Statements that one resource definition can be deployed to any cloud are false.

Hybrid cloud

A hybrid cloud combines private infrastructure, such as a VMware vSphere cluster or on-premises network devices, with public clouds. Providers for vSphere, Nutanix, network vendors and on-premises Kubernetes let Terraform manage the private side with the same workflow. A single change can provision a virtual machine on premises, a managed database in a public cloud and the firewall rules between them, all reviewed in one plan.

Terraform itself can run anywhere that can reach the APIs. When the private APIs are not reachable from the internet, HCP Terraform agents run inside the private network, so remote runs can still manage on-premises infrastructure.

Scenario questions

Reaching private infrastructure

Exam skills 1.3.2

Apply Terraform to infrastructure that is not in a public cloud.

Log in to try this activity Interactive activities are free with an account.
Worked example

One tool or many

A company runs its web tier on AWS, its analytics on Google Cloud and its legacy applications on an on-premises vSphere cluster. Each team uses a different tool, and changes that span two platforms are coordinated by email. What does Terraform offer?

The decisive requirement is coordinated changes across platforms.

With Terraform, each platform is a provider in the same workflow. A cross-platform change, such as opening a connection from the analytics platform to a legacy database, becomes one pull request whose plan shows the changes on both platforms, applied in dependency order. Teams still write platform-specific resources, but they share one language, one review process and one way to store state.

Check yourself

Can an aws_instance resource block be deployed to Azure by changing the provider configuration?

Show answer

No. Resource types are platform-specific; Terraform offers a common workflow and language, not portable resource definitions.

Exam Tips

Remember for the exam

  • One language and workflow for any platform with a provider.
  • Multi-cloud: several providers in one configuration and one plan.
  • Hybrid: on-premises platforms have providers too.
  • Resources are platform-specific; the workflow is shared.