Learn how to use multiple cloud providers in a single Terraform configuration — including cross-provider references and state sharing.

What Will You Learn? #

Many organizations use a multi-cloud or multi-region strategy. Terraform supports using several providers simultaneously, letting you manage resources on AWS, GCP, Azure, and other providers in one integrated configuration.

Articles in This Section #

ArticleMain Topic
What is Multi Provider?The concept of multi-provider and its use cases
Cross Provider ReferenceConnecting resources across providers (e.g., AWS EC2 → Cloudflare DNS)
State SharingSharing state between different Terraform configurations

Multi-Provider Architecture #

flowchart TD
    subgraph Terraform
        P_AWS["AWS Provider<br/>region = us-east-1"]
        P_GCP["GCP Provider<br/>project = my-project"]
        P_CF["Cloudflare Provider<br/>zone = example.com"]
    end

    subgraph Resources
        EC2["AWS EC2"]
        GKE["GCP GKE"]
        DNS["Cloudflare DNS"]
    end

    P_AWS --> EC2
    P_GCP --> GKE
    P_CF --> DNS
    EC2 -.->|"IP reference"| DNS

    style Terraform fill:#e3f2fd
    style Resources fill:#e8f5e9

Cross-Provider Reference #

flowchart LR
    subgraph AWS
        LB["AWS ALB<br/>dns_name"]
    end

    subgraph Cloudflare
        CNAME["CNAME Record<br/>pointing to the ALB"]
    end

    subgraph Datadog
        MONITOR["Monitor<br/>health check"]
    end

    LB -->|"cross-ref"| CNAME
    LB -->|"cross-ref"| MONITOR

    style AWS fill:#fff3e0
    style Cloudflare fill:#f3e5f5
    style Datadog fill:#e3f2fd

State Sharing Methods #

flowchart TD
    subgraph Method1["terraform_remote_state"]
        RS["Read outputs from\nanother state file"]
    end

    subgraph Method2["Data Sources"]
        DS["Query the cloud\nAPI directly"]
    end

    subgraph Method3["Explicit Output"]
        EO["Pass outputs manually\nbetween configs"]
    end

    Method1 --> Use["Cross-stack\nreference"]
    Method2 --> Use
    Method3 --> Use

    style Method1 fill:#e3f2fd
    style Method2 fill:#e8f5e9
    style Method3 fill:#fff3e0

Multi-provider setups require good planning. Continue to CI/CD to learn how to automate Terraform deployments.

About | Author | Content Scope | Editorial Policy | Privacy Policy | Disclaimer | Contact