Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

2.2.1. Provider Configuration and Aliases

💡 First Principle: The provider block configures how to talk to a platform (region, credentials, endpoints), and an alias lets you keep several such configurations side by side so each resource can point at the one it needs.

A bare provider block is the default configuration for that provider. Adding alias = "..." creates an additional named configuration:

provider "aws" {
  region = "us-east-1"           # default configuration
}

provider "aws" {
  alias  = "west"
  region = "us-west-2"           # additional configuration
}

resource "aws_instance" "east" {
  # uses the default aws provider
}

resource "aws_instance" "west" {
  provider = aws.west            # explicitly selects the aliased one
}

Resources use the default provider unless they set the provider meta-argument to an aliased reference like aws.west. This is the standard pattern for deploying the same resources across regions or accounts from one configuration. (Some providers add their own shortcut — AWS provider 6.0+ accepts a per-resource region argument — but aliases are the provider-agnostic mechanism, and what you still need when resources must use different credentials or accounts.)

⚠️ Exam Trap: Don't confuse the provider block (configures a provider instance) with the provider meta-argument (selects which configured instance a resource uses). The block defines the line; the meta-argument dials it.

Reflection Question: Why does deploying to two accounts with different credentials require two provider configurations, and how does each resource choose between them?

See how it connects
Alvin Varughese
Written byAlvin Varughese
Founder•20 professional certifications