Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      This week in AI dev tools: Gemini 2.5 Pro and Flash GA, GitHub Copilot Spaces, and more (June 20, 2025)

      June 20, 2025

      Gemini 2.5 Pro and Flash are generally available and Gemini 2.5 Flash-Lite preview is announced

      June 19, 2025

      CSS Cascade Layers Vs. BEM Vs. Utility Classes: Specificity Control

      June 19, 2025

      IBM launches new integration to help unify AI security and governance

      June 18, 2025

      One of World of Warcraft’s deadliest entities makes a world-shattering return after nearly 20 years — and he’s city-sized

      June 20, 2025

      It feels like Blizzard has abandoned Diablo 2: Resurrected — but there’s one way to keep it alive for years to come

      June 20, 2025

      Steam’s performance tracking tool is becoming more like the Steam Deck’s — you can try it out right now

      June 20, 2025

      Borderlands 4 is killing off a tired “FOMO” trend — I hope other developers follow suit

      June 20, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Dr. Axel’s JavaScript flashcards

      June 20, 2025
      Recent

      Dr. Axel’s JavaScript flashcards

      June 20, 2025

      Syntax-Highlight – Custom Element For Syntax Highlighting Content

      June 20, 2025

      WelsonJS – Build a Windows app on the Windows built-in JavaScript engine

      June 20, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      One of World of Warcraft’s deadliest entities makes a world-shattering return after nearly 20 years — and he’s city-sized

      June 20, 2025
      Recent

      One of World of Warcraft’s deadliest entities makes a world-shattering return after nearly 20 years — and he’s city-sized

      June 20, 2025

      It feels like Blizzard has abandoned Diablo 2: Resurrected — but there’s one way to keep it alive for years to come

      June 20, 2025

      Steam’s performance tracking tool is becoming more like the Steam Deck’s — you can try it out right now

      June 20, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Operating Systems»Linux»Managing Providers in Terraform: AWS, Azure, and GCP

    Managing Providers in Terraform: AWS, Azure, and GCP

    June 18, 2025

    Hey Infra Coders, Let’s Talk Providers!

    Welcome back, Infra coders! You’ve already written your first Terraform configuration and created some cool AWS resources like an S3 bucket and an EC2 instance. Now, let’s take it up a notch by exploring providers—the magic behind Terraform’s ability to work with different cloud platforms. In this article, we’ll learn how to manage providers for AWS, Azure, and Google Cloud Platform (GCP) in the same Terraform project. Think of providers as your bridge to different clouds, and we’re about to become bridge-building experts!

    We’ll set up a configuration that creates resources across AWS, Azure, and GCP, and I’ll walk you through each step in plain English. Ready? Let’s dive in!

    Terraform Providers

    What Are Providers in Terraform?

    A provider in Terraform is like a translator that lets Terraform talk to a specific platform, like AWS, Azure, or GCP. Each provider has its own plugin that knows how to create, update, or delete resources on that platform. Terraform supports hundreds of providers, from cloud platforms to tools like Kubernetes or GitHub, but today we’ll focus on the big three: AWS, Azure, and GCP.

    You can use multiple providers in one Terraform project, which is super powerful for hybrid or multi-cloud setups. For example, you might store files in an AWS S3 bucket, run a virtual machine in Azure, and manage a database in GCP—all with one Terraform configuration.

    Step 1: Set Up Your Project

    Let’s create a new folder for this project called multi-cloud. Inside it, create a file named main.tf. This will hold our configuration for all three providers. You’ll need accounts for AWS, Azure, and GCP, but if you don’t have all of them, you can still follow along and test with the ones you have.

    Prerequisites

    Before we start, make sure you have:

    • Terraform installed (check with terraform -version).
    • An AWS account with access keys set up in ~/.aws/credentials.
    • An Azure account with a service principal (we’ll cover how to set this up).
    • A GCP account with a service account key (we’ll set this up too).
    • A text editor like VS Code.

    Step 2: Configure the AWS Provider

    Let’s start with AWS, since you’re already familiar with it. Add this to your main.tf:

    
    provider "aws" {
      region = "us-east-1"
    }
    
    

    This sets up the AWS provider in the us-east-1 region. Your credentials in ~/.aws/credentials will be used automatically. We’ll create an S3 bucket later in the configuration.

    Step 3: Configure the Azure Provider

    Next, let’s add Azure. To use Terraform with Azure, you need a service principal for authentication. Here’s how to set it up:

    Get Azure Credentials

    1. Log into the Azure Portal.
    2. Go to Azure Active Directory → App registrations → New registration.
    3. Create an app, then note the Application (client) ID and Directory (tenant) ID.
    4. Create a Client secret under Certificates & secrets and save it.
    5. Go to Subscriptions, note your Subscription ID, and assign your app Contributor role under Access control (IAM).

    Now, add the Azure provider to main.tf:

    
    provider "azurerm" {
      features {}
      subscription_id = "your-subscription-id"
      client_id       = "your-client-id"
      client_secret   = "your-client-secret"
      tenant_id       = "your-tenant-id"
    }
    
    

    Replace the placeholders with your actual Azure credentials. The features {} block is required for the Azure provider.

    Step 4: Configure the GCP Provider

    For GCP, you need a service account key. Here’s how to get it:

    Get GCP Credentials

    1. Go to the GCP Console.
    2. Navigate to IAM & Admin → Service Accounts → Create Service Account.
    3. Give it a name, grant Editor role (for this tutorial), and create a JSON key.
    4. Download the JSON key file and save it securely (e.g., gcp-key.json).

    Add the GCP provider to main.tf:

    
    provider "google" {
      project     = "your-gcp-project-id"
      region      = "us-central1"
      credentials = file("gcp-key.json")
    }
    
    

    Replace your-gcp-project-id with your GCP project ID, and make sure gcp-key.json is in your multi-cloud folder.

    Terraform Providers - AWS, Azure and GCP

    Step 5: Create Resources Across Providers

    Now, let’s create one resource in each cloud to see providers in action:

    • AWS: An S3 bucket.
    • Azure: A resource group.
    • GCP: A Cloud Storage bucket.

    Add this to main.tf:

    
    # AWS S3 Bucket
    resource "aws_s3_bucket" "my_aws_bucket" {
      bucket = "my-unique-bucket-12345"
    }
    
    # Azure Resource Group
    resource "azurerm_resource_group" "my_azure_group" {
      name     = "my-terraform-group"
      location = "East US"
    }
    
    # GCP Cloud Storage Bucket
    resource "google_storage_bucket" "my_gcp_bucket" {
      name     = "my-unique-gcp-bucket-12345"
      location = "US"
    }
    
    

    What’s happening here?

    • AWS: Creates an S3 bucket (use a unique name).
    • Azure: Creates a resource group, a container for Azure resources.
    • GCP: Creates a Cloud Storage bucket (use a unique name).

    Pro Tip

    Bucket names in AWS and GCP must be globally unique, so add random numbers or your name to avoid conflicts.

    Step 6: Run Your Terraform Commands

    Let’s bring this configuration to life. In your multi-cloud folder, run these commands:

    Initialize Terraform

    
    terraform init
    
    

    This downloads plugins for AWS, Azure, and GCP providers.

    Preview the Plan

    
    terraform plan
    
    

    Terraform will show a plan to create one resource in each cloud. Double-check the output.

    Apply the Configuration

    
    terraform apply
    
    

    Type yes to confirm, and Terraform will create the resources. Check your AWS, Azure, and GCP consoles to see the bucket, resource group, and storage bucket.

    Step 7: Clean Up

    To avoid costs, clean up by running:

    
    terraform destroy
    
    

    Type yes to delete all resources. Verify in each cloud console that they’re gone.

    Your Complete main.tf File

    Here’s the full main.tf for reference:

    
    provider "aws" {
      region = "us-east-1"
    }
    
    provider "azurerm" {
      features {}
      subscription_id = "your-subscription-id"
      client_id       = "your-client-id"
      client_secret   = "your-client-secret"
      tenant_id       = "your-tenant-id"
    }
    
    provider "google" {
      project     = "your-gcp-project-id"
      region      = "us-central1"
      credentials = file("gcp-key.json")
    }
    
    resource "aws_s3_bucket" "my_aws_bucket" {
      bucket = "my-unique-bucket-12345"
    }
    
    resource "azurerm_resource_group" "my_azure_group" {
      name     = "my-terraform-group"
      location = "East US"
    }
    
    resource "google_storage_bucket" "my_gcp_bucket" {
      name     = "my-unique-gcp-bucket-12345"
      location = "US"
    }
    
    

    Tips for Managing Multiple Providers

    You’re now managing multiple clouds—nice work! Here are some tips to keep things smooth:

    • Secure Credentials: Never hardcode secrets in .tf files. Use files like ~/.aws/credentials or environment variables.
    • Organize Providers: For complex projects, put each provider’s resources in separate .tf files (e.g., aws.tf, azure.tf).
    • Check Free Tiers: Use free-tier resources to avoid unexpected costs.
    • Use Version Control: Save your code in Git to track changes and collaborate.

    What’s Next?

    You just built a multi-cloud setup with Terraform—pretty awesome, right? In the next article, we’ll dive into Terraform state management, learning how Terraform keeps track of your infrastructure and how to manage it safely. Keep your multi-cloud folder handy, and let’s keep building, Infra coders!

    The post Managing Providers in Terraform: AWS, Azure, and GCP appeared first on TecAdmin.

    Source: Read More

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleGitHub Copilot Spaces: Bring the right context to every suggestion
    Next Article CVE-2025-20260 – ClamAV PDF Buffer Overflow Vulnerability

    Related Posts

    News & Updates

    One of World of Warcraft’s deadliest entities makes a world-shattering return after nearly 20 years — and he’s city-sized

    June 20, 2025
    News & Updates

    It feels like Blizzard has abandoned Diablo 2: Resurrected — but there’s one way to keep it alive for years to come

    June 20, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    CVE-2025-4262 – “PHPGurukul Online DJ Booking Management System SQL Injection Vulnerability”

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-4365 – Citrix NetScaler Console and NetScaler SDX SVM Arbitrary File Read Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-4453 – D-Link DIR-619L Remote Command Injection Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Motherhood and Career Balance in Tech: Stories from Perficient LATAM

    Development

    Highlights

    News & Updates

    One of World of Warcraft’s deadliest entities makes a world-shattering return after nearly 20 years — and he’s city-sized

    June 20, 2025

    Blizzard has revealed the next content update for World of Warcraft: The War Within, titled…

    CVE-2025-4920 – Mozilla Firefox Promise Object Out-of-Bounds Read/Write Vulnerability

    May 17, 2025

    CVE-2025-43571 – Substance3D Use After Free Vulnerability

    May 13, 2025

    TUXEDO InfinityBook Pro 14 Gen10: il nuovo portatile Linux con AMD Ryzen AI 300

    June 14, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.