Search⌘ K
AI Features

More Than One Instance of the Same Provider

Explore how to create and manage multiple instances of the same Terraform provider to deploy AWS resources across different regions. Understand using provider aliases and assigning resources to specific providers for efficient infrastructure management.

Creating multiple instances of the same provider

Since region is a required parameter in the AWS provider, you may be wondering how to create resources in different regions. Is that possible in a single Terraform project? Well, yes, it is. To do this, you simply create multiple instances of the same provider.

Project example

Consider the following project:



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

provider "aws" {
    region = "us-east-2"
    alias = "ohio"
}

resource "aws_vpc" "n_virginia_vpc" {
    cidr_block = "10.0.0.0/16"
}

resource "aws_vpc" "ohio_vpc" {
    cidr_block = "10.1.0.0/16"
    provider = aws.ohio
}

AWS provider instances

As you can see, we are defining two instances of the AWS provider. One points at the region us-east-1 while the other points at the region us-east-2. For the one that is pointing at us-east-2, ...