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

      This week in AI dev tools: Gemini API Batch Mode, Amazon SageMaker AI updates, and more (July 11, 2025)

      July 11, 2025

      JFrog finds MCP-related vulnerability, highlighting need for stronger focus on security in MCP ecosystem

      July 11, 2025

      8 Key Questions Every CEO Should Ask Before Hiring a Node.js Development Company in 2025

      July 11, 2025

      Vibe Loop: AI-native reliability engineering for the real world

      July 10, 2025

      DistroWatch Weekly, Issue 1130

      July 13, 2025

      Distribution Release: GParted Live 1.7.0-8

      July 13, 2025

      Distribution Release: CachyOS 250713

      July 13, 2025

      Most AI projects are abandoned – 5 ways to ensure your data efforts succeed

      July 13, 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

      The details of TC39’s last meeting

      July 13, 2025
      Recent

      The details of TC39’s last meeting

      July 13, 2025

      new Date(“wtf”) – How well do you know JavaScript’s Date class?

      July 12, 2025

      Francisco Bergeret Paves the Way Through Strong Leadership at Perficient

      July 11, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      DistroWatch Weekly, Issue 1130

      July 13, 2025
      Recent

      DistroWatch Weekly, Issue 1130

      July 13, 2025

      Distribution Release: GParted Live 1.7.0-8

      July 13, 2025

      Distribution Release: CachyOS 250713

      July 13, 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

    DistroWatch Weekly, Issue 1130

    July 13, 2025
    News & Updates

    Distribution Release: GParted Live 1.7.0-8

    July 13, 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

    Is Anxiety Disorder a Neurological Disorder?

    Web Development

    How to Remove Trojan:PowerShell/DownInfo.BA from Windows

    Operating Systems

    ast-grep performs structural search, lint and rewriting

    Linux

    CVE-2025-25265 – Apache Controller File Disclosure

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    CVE-2025-2771 – BEC Technologies Router Authentication Bypass Vulnerability

    April 23, 2025

    CVE ID : CVE-2025-2771

    Published : April 23, 2025, 5:16 p.m. | 1 hour, 42 minutes ago

    Description : BEC Technologies Multiple Routers Authentication Bypass Vulnerability. This vulnerability allows remote attackers to bypass authentication on affected installations of BEC Technologies routers. Authentication is not required to exploit this vulnerability.

    The specific flaw exists within the web-based user interface. The issue results from the lack of authentication prior to allowing access to functionality. An attacker can leverage this vulnerability to bypass authentication on the system. Was ZDI-CAN-25894.

    Severity: 5.3 | MEDIUM

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    CVE-2025-3506 – Checkmk Unauthenticated File Access Vulnerability

    May 8, 2025

    CVE-2025-29007 – LMSACE Connect Missing Authorization Vulnerability

    July 4, 2025

    Dell says Windows 11’s next-gen ARM PCs to improve external monitor support

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

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