Skip to main content

Terraform AWS provider 6.0 now generally available

HashiCorp and AWS continue to support the widespread demand for standardized infrastructure lifecycle management with the Terraform AWS provider 6.0.

The Terraform AWS provider serves as the bridge between Terraform configurations and AWS, enabling users to define and manage AWS resources as code. We are excited to share that version 6.0 of the Terraform AWS provider is now generally available. Along with bugfixes, the latest update brings enhanced multi-region support and other workflow improvements.

With this release, AWS and HashiCorp continue to expand their partnership — delivering new integrations that help customers move faster, adopt more AWS services and features, and deploy infrastructure with developer-friendly workflows.

»Enhanced region support

Previously in the Terraform AWS provider, each provider configuration targeted a single AWS region. With this limitation, practitioners had to update every configuration file individually if they wanted to change a particular resource’s configuration. For global companies, this could mean editing the same parameter in up to 32 separate configuration files for each region.

With 6.0, the AWS provider now supports multiple regions all within a single configuration file. This new approach leverages an injected region attribute at the resource level to simplify configuration efforts. This method also reduces the need to load multiple instances of the AWS provider, lowering memory usage overall.

Here are some more key highlights in this feature:

  • Single provider configuration: Reduces the need to load multiple instances of the AWS provider, lowering memory usage.
  • Region attribute injection: The region argument is added to all resources (except global resources) without requiring explicit schema changes.
  • Global resources exclusion: Services like IAM, CloudFront, and Route 53 remain unaffected as they operate globally.
  • Terraform plugin framework updates: Adjustments to the AWS API client mechanism support per-region API client mappings.
  • Resource import enhancements: A new @<regionID> suffix allows importing of resources from different regions.
  • Documentation and testing: Changes are documented at the provider level and tested to ensure backward compatibility.

This example shows how to use the new region attribute for the aws_vpc_peering_connection_accepter in your Terraform configuration:

provider "aws" {
  region = "us-east-1"
}
 
resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}
 
resource "aws_vpc" "peer" {
  region = "us-west-2"
 
  cidr_block = "10.1.0.0/16"
}
 
# Requester's side of the connection.
resource "aws_vpc_peering_connection" "main" {
  vpc_id      = aws_vpc.main.id
  peer_vpc_id = aws_vpc.peer.id
  peer_region = "us-west-2"
  auto_accept = false
}
 
# Accepter's side of the connection.
resource "aws_vpc_peering_connection_accepter" "peer" {
  region = "us-west-2"
 
  vpc_peering_connection_id = aws_vpc_peering_connection.main.id
  auto_accept               = true
}

This is an example of how to use the new region attribute for the aws_kms_replica_key in your Terraform configuration:

provider "aws" {
  region = "us-west-2"
}
 
resource "aws_kms_key" "primary" {
  region = "us-east-1"
 
  description             = "Multi-Region primary key"
  deletion_window_in_days = 30
  multi_region            = true
}
 
resource "aws_kms_replica_key" "replica" {
  description             = "Multi-Region replica key"
  deletion_window_in_days = 7
  primary_key_arn         = aws_kms_key.primary.arn
}

»Migrating configuration to use the new region parameter

In many cases, practitioners have used mechanisms such as creating aliases to build configurations that span across multiple AWS Regions. For example:

provider "aws" {
  region = "us-east-1"
}
 
provider "aws" {
  alias  = "peer"
  region = "us-west-2"
}
 
resource "aws_kms_key" "test" {
  provider = aws.peer
 
  description  = "Multi-Region primary key"
  multi_region = true
}
 
resource "aws_kms_replica_key" "test" {
  description     = "Multi-Region replica key"
  primary_key_arn = aws_kms_key.test.arn
}

To migrate from a separate provider configuration for each Region to a single provider configuration block and per-resource region values you must ensure that Terraform state is refreshed before editing resource configuration:

  1. Upgrade to version 6.0
  2. Run a Terraform plan in refresh-only modeterraform plan -refresh-only
  3. Run a Terraform apply in refresh-only modeterraform apply -refresh-only
  4. Modify the affected resource configurations, replacing the provider meta-argument with a region argument. For example:
provider "aws" {
  region = "us-east-1"
}
 
resource "aws_kms_key" "test" {
  region = "us-west-2"
 
  description  = "Multi-Region primary key"
  multi_region = true
}
 
resource "aws_kms_replica_key" "test" {
  description     = "Multi-Region replica key"
  primary_key_arn = aws_kms_key.test.arn
}

»Getting started

The Terraform AWS provider 6.0 is now available for use in the Terraform Registry. When upgrading to version 6.0 of the Terraform AWS provider, please consult the upgrade guide on the Terraform Registry as it contains not only a list of changes but also examples. Because this release introduces breaking changes, we recommend pinning your provider version to protect against unexpected results.

For the full list of updates in version 6.0, please refer to the summary of changes on GitHub. To learn the basics of Terraform using this provider, follow the hands-on tutorials for getting started with Terraform on AWS on our developer education platform. Interact with AWS services, including AWS Lambda, Amazon RDS, and AWS IAM by following the AWS services tutorials.

If you are currently using Terraform Community Edition or are completely new to Terraform, try HCP Terraform for free today.

Sign up for the latest HashiCorp news

By submitting this form, you acknowledge and agree that HashiCorp will process your personal information in accordance with the Privacy Policy.