Terraform enables declarative management of cloud infrastructure through provider plugins. The Terraform AWS provider is the plugin that connects Terraform to Amazon Web Services APIs and allows configuration, creation, modification, and reading of AWS resources using Terraform’s declarative configuration language. Providers are specified in the Terraform configuration, allowing users to define the specific services and resources they need to manage and provision.
The AWS provider lets Terraform interact with various cloud platforms, such as AWS, infrastructure providers, and other third-party services. Before using this provider, you must configure it with the appropriate credentials to authenticate and authorize access to your AWS account.
What Is a Terraform Provider
A provider in Terraform is a plugin that enables communication with external APIs and services. It lets Terraform interact with various cloud platforms, such as AWS, infrastructure providers, and other third-party services.
In Terraform, a provider is a plugin that interacts with cloud providers, third-party tools, and other APIs. To use Terraform with AWS, you use the AWS Provider. This distinction adds an extra layer of complexity to Terraform that doesn't exist with CloudFormation. However, that complexity provides increased flexibility. You can declare multiple providers within a single Terraform module, and then the underlying resources that are created can interact with each other as part of the same deployment layer.
Providers don’t necessarily have to be for separate cloud providers. Providers can represent any source for cloud resources. For example, take Amazon Elastic Kubernetes Service. When you provision an Amazon EKS cluster, you might want to use Helm charts to manage third-party extensions and use Kubernetes itself to manage pod resources.
What Is the Terraform AWS Provider
The Terraform AWS provider is a plugin that enables seamless integration between Terraform and the Amazon Web Services cloud platform. It allows users to define, provision, and manage AWS resources using Terraform’s declarative configuration language.
The Terraform AWS provider is the plugin Terraform uses to talk to AWS APIs so your configuration can create, update, and read AWS resources like VPCs, IAM roles, S3 buckets, and EC2 instances. You configure it in a provider "aws" block, region plus credentials via env vars, profiles, or assumed roles, then reference its resources and data sources in your code.
Key features of the Terraform AWS provider
As for the majority of Terraform providers, the Terraform AWS provider comes with the following key features:
- Resource management – create/modify/delete AWS resources based on your Terraform configuration, such as EC2 instances, VPCs, load balancers, S3 buckets, and others
- Data sources – get information about existing AWS resources
- State management with S3 and Dynamo DB – you can use AWS for remote state management using S3 to host the state and Dynamo DB for locking
- Great modules community – Because AWS is the leader cloud provider, it also has the biggest modules community
Core Capabilities
| Capability | Description |
|---|---|
| Resource management | Create, modify, and delete AWS resources from Terraform configuration |
| Data sources | Query information about existing AWS resources |
| Remote state | Use S3 for state storage and DynamoDB for state locking |
| Module ecosystem | Access to large community of AWS modules |
Setup Workflow for the AWS Provider
The process for using the Terraform AWS provider is the following:
- Provider configuration
- AWS resource configuration
- Initializing Terraform to install the provider
- Running Terraform apply to create the resources
1. Configure the Provider
You can configure your AWS provider in many ways.
Because Terraform can read information from your environment if you have set up your AWS credentials, you could configure the provider just by specifying the region:
hcl
provider "aws" {
region = "eu-west-1"
}
If we don’t specify a Terraform block with a version constraint for the provider, Terraform will automatically download the latest available version of the AWS provider.
At the time of writing, the latest version of the AWS provider is 5.51.1. Let’s add a Terraform block that makes us use the 5.50.0 version:
hcl
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.50.0"
}
}
}
2. Define AWS Resources
Based on the provider above, we can configure AWS resources. For this example, we will just configure an AWS VPC:
hcl
resource "aws_vpc" "this" {
cidr_block = "10.0.0.0/16"
}
You can configure as many resources as you want.
Terraform AWS Provider Configuration Options
What are the Terraform AWS provider configuration options?
The most important Terraform AWS provider options include:
- region – specify the AWS region in which we want to create your resources
- access_key – the AWS access key we use for authenticating to the provider
- secret_key – the AWS secret key associated with our access key
- assume_role – configuration block for specifying what role we want to use to authenticate with AWS
- token – session token for temporary credentials
You can look here for all the options you can configure for your AWS provider.
| Option | Purpose |
|---|---|
| region | AWS region for resource creation |
| access_key | AWS access key for authentication |
| secret_key | AWS secret key associated with access key |
| assume_role | Role to assume for authentication |
| token | Session token for temporary credentials |
Authentication to AWS with Terraform
How to authenticate to AWS with Terraform
There are many ways to authenticate using the Terraform AWS provider.
The TL;DR guidance is that you configure it in a provider "aws" block, region plus credentials via env vars, profiles, or assumed roles, then reference its resources and data sources in your code.
Provider configuration can rely on environment variables, named profiles, or explicit credentials. The provider block can be minimal when credentials are present in the environment.
Assuming IAM roles with the Terraform AWS provider is supported via the assume_role configuration block. This allows the provider to authenticate to AWS using a role rather than long-lived keys.
Provider Version Management and Upgrades
How to upgrade the Terraform AWS provider to the newest version?
Version pinning is done via the terraform required_providers block. Without a version constraint, Terraform will automatically download the latest available version of the AWS provider.
Explicit version constraints give repeatable builds. For example, specifying version = "5.50.0" locks the configuration to that release. The latest version referenced in the material is 5.51.1.
Best Practices for Using the Terraform AWS Provider
Best practices for using the Terraform AWS Provider
Michael Begin, Senior DevOps Consultant, Amazon Web Services, August 2025
Managing infrastructure as code with Terraform on AWS offers important benefits such as improved consistency, security, and agility. However, as your Terraform configuration grows in size and complexity, it becomes critical to follow best practices to avoid pitfalls.
This guide provides recommended best practices for using the Terraform AWS Provider.
Objectives
This guide helps you gain operational knowledge on the Terraform AWS Provider and addresses the following business goals that you can achieve by following IaC best practices around security, reliability, compliance, and developer productivity.
- Improve infrastructure code quality and consistency across Terraform projects.
- Accelerate developer onboarding and ability to contribute to infrastructure code.
- Increase business agility through faster infrastructure changes.
- Reduce errors and downtime related to infrastructure changes.
- Optimize infrastructure costs by following IaC best practices.
- Strengthen your overall security posture through best practice implementation.
Target audience
The target audience for this guide includes technical leads and managers who oversee teams that use Terraform for IaC on AWS.
The guide is published as Best practices for using the Terraform AWS Provider with document history August 2025.
Common Issues and Troubleshooting
Terraform AWS provider – Common issues and troubleshooting is covered in the overview of what the AWS provider is in Terraform and everything from basic concepts to advanced configuration and authentication methods for managing AWS resources using Terraform.
The workflow steps help isolate problems:
- Provider configuration errors typically relate to missing region or credentials
- AWS resource configuration errors relate to invalid arguments or dependencies
- Initializing Terraform to install the provider may fail if network or registry access is blocked
- Running Terraform apply to create the resources may fail due to permission issues
State management with S3 and Dynamo DB is recommended for team use to avoid state corruption and enable locking.
What We Cover
In this article, we will give an overview of what the AWS provider is in Terraform and show everything from basic concepts to advanced configuration and authentication methods for managing AWS resources using Terraform.
What we will cover:
- What is a Terraform provider?
- What is the Terraform AWS provider?
- How to set up the Terraform AWS provider?
- Terraform AWS provider configuration options
- Authenticating to AWS with Terraform
- Assuming IAM roles with the Terraform AWS provider
- How to upgrade the Terraform AWS provider to the newest version?
- Terraform AWS provider – Common issues and troubleshooting
Conclusion
The Terraform AWS provider is central to infrastructure as code on AWS. It provides resource management for EC2 instances, VPCs, load balancers, S3 buckets, and others, data sources for querying existing resources, and remote state management with S3 and DynamoDB for locking and consistency. The provider is configured via a provider "aws" block with options such as region, accesskey, secretkey, assume_role, and token, and can be used with environment variables, profiles, or assumed roles.
Setup follows a clear sequence: provider configuration, AWS resource configuration, initializing Terraform to install the provider, and running Terraform apply to create the resources. Version control is achieved through the required_providers block, with examples referencing version 5.50.0 and latest version 5.51.1 at time of writing.
Best practices published by AWS emphasize code quality, consistency, developer onboarding, agility, error reduction, cost optimization, and security posture. These goals are pursued by technical leads and managers overseeing Terraform on AWS.
Understanding provider flexibility, authentication options, and state management enables reliable, scalable, and secure AWS infrastructure management with Terraform.