Skip to content

Multiple Provider Configurations

Step-01: Introduction

  • Understand and Implement Multiple Provider Configurations

Step-02: How to define multiple provider configuration of same Provider?

  • Understand about default provider
  • Understand and define multiple provider configurations of same provider
# Provider-1 for us-east-1 (Default Provider)
provider "aws" {
  region = "us-east-1"
  profile = "default"

# Provider-2 for us-west-1
provider "aws" {
  region = "us-west-1"
  profile = "default"
  alias = "aws-west-1"

Step-03: How to reference the non-default provider configuration in a resource?

# Resource Block to Create VPC in us-west-1
resource "aws_vpc" "vpc-us-west-1" {
  cidr_block = ""
  provider =
  tags = {
    "Name" = "vpc-us-west-1"

Step-04: Execute Terraform Commands

# Initialize Terraform
terraform init

# Validate Terraform Configuration Files
terraform validate

# Generate Terraform Plan
terraform plan

# Create Resources
terraform apply -auto-approve

# Verify the same
1. Verify the VPC created in us-east-1
2. Verify the VPC created in us-west-2

Step-05: Clean-Up

# Destroy Terraform Resources
terraform destroy -auto-approve

# Delete Terraform Files
rm -rf .terraform*
rm -rf terraform.tfstate*