AWS Amplify is great for developers who want a managed hosting experience, but enterprise teams often need their infrastructure defined in Terraform alongside everything else. Instead of clicking through the Amplify console or using the Amplify CLI separately from your other infrastructure, you can manage Amplify resources entirely through Terraform.
This guide covers provisioning Amplify apps, branches, domain associations, webhooks, and related backend resources using Terraform. By the end, your entire Amplify setup will be reproducible and version-controlled.
Using Terraform for Amplify gives you:
- A single source of truth for all infrastructure
- Consistent state management across resources
- Drift detection and automated reconciliation
- The ability to create identical environments with terraform workspace
- Integration with your existing CI/CD pipelines
If your organization already uses Terraform for VPCs, databases, and other AWS resources, managing Amplify separately creates a gap in your infrastructure-as-code strategy.
Why Terraform for Amplify
AWS Amplify is a powerful tool that can help you build and deploy full-stack applications with ease. Terraform is an infrastructure as code tool that allows you to manage your cloud infrastructure in a declarative manner. In this tutorial, we will show you how to deploy AWS Amplify using Terraform.
Terraform allows you to manage your infrastructure as code, which means that you can version control your infrastructure and easily reproduce it across multiple environments. By following the steps outlined in this tutorial, you can easily deploy your Amplify app using Terraform and have full control over your cloud infrastructure.
The service provides a unified model to manage backend and frontend development workflows, and it helps to seamlessly integrate with other AWS services.
The terraform-aws-amplify module simplifies the deployment process of a web site by automatically deploying it from an existing S3 bucket to a new AWS Amplify service that it sets up for you.
Prerequisites
You need:
- Terraform 1.0 or later installed
- AWS credentials configured
- A Git repository with your frontend application
- A GitHub personal access token for repository connection
The first step is to install Terraform and the AWS CLI on your machine. You can download Terraform from the official website, and the AWS CLI can be installed using pip. Once you have installed these tools, you can move on to the next step.
Start the AWS command-line interface running on your workstation so that you can authenticate with AWS.
For this tutorial, create a React.js app using the command below. I will assume that you already have an understanding of using Terraform and AWS.
Provider and State Configuration
Step 1: Configure the AWS Provider
Start with your Terraform configuration:
hcl
terraform {
required_version = ">= 1.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
backend "s3" {
bucket = "my-terraform-state"
key = "amplify/terraform.tfstate"
region = "us-east-1"
}
}
provider "aws" {
region = var.aws_region
}
The minimum supported Terraform version is 1.3.0 for the JetBrains module.
| Name | Version |
|---|---|
| terraform | >= 1.3 |
| aws | >= 5.20 |
| Name | Version |
|---|---|
| aws | >= 5.20 |
| Name | Type |
|---|---|
| awsamplifyapp.site | resource |
| awsamplifybranch.site | resource |
Core Amplify App Resource
Step 2: Create the Amplify App Resource
The awsamplifyapp resource creates the Amplify application:
hcl
resource "aws_amplify_app" "main" {
name = var.app_name
repository = var.repository_url
access_token = var.github_access_token
build_spec = <<-EOT
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
EOT
}
An alternative definition is:
hcl
resource "aws_amplify_app" "amplify_app" {
name = var.app_name
repository = var.repository
oauth_token = var.token
}
AWS Amplify with Terraform
Recently I needed to set up the infrastructure to deploy a small React progressive web application to the cloud. This application was essentially a static site with no backend. I would also need to set up the infrastructure for this project using Terraform.
Amplify is an AWS service offering that allows you to easily deploy full-stack applications or static sites really easily. It allows you to either connect to a repository or to do manual deploys where you can either point it at an S3 bucket or upload a zip file containing your site. Another neat feature is it performs an automatic ui check for your deployed application against a few common devices so you can check that it is rendering correctly on different screen sizes. There are many other great features such as monitoring and automatic branch creation that you can read about here.
For the purposes of this article we will assume that we already have a React application that we want to deploy. The content or code of the application is not important as we will be focusing on setting up the infrastructure not developing the application. We will be making use of AWS Amplify’s managed deployments where we connect a CodeCommit repository to Amplify so that when we push changes to our repository, our application will automatically deploy the changes.
We will also be using Terraform to set up our AWS infrastructure
Branch and Domain Association
Create a folder named amplify in your home directory. With in the amplify folder create a file named main.tf. The file should include the following code:
hcl
resource "aws_amplify_branch" "amplify_branch" {
app_id = aws_amplify_app.amplify_app.id
branch_name = var.branch_name
}
hcl
resource "aws_amplify_domain_association" "domain_association" {
app_id = aws_amplify_app.amplify_app.id
domain_name = var.domain_name
wait_for_verification = false
sub_domain {
branch_name = aws_amplify_branch.amplify_branch.branch_name
prefix = var.branch_name
}
}
This code defines an Amplify app, branch, and domain.
Terraform enables you to automate the provision and management of your AWS Amplify resources. Once you’ve defined your changes in the declarative configuration language, Terraform will apply the changes automatically, reducing any manual or human intervention.
Module-Based Deployment
The terraform-aws-amplify module simplifies the deployment process of a web site by automatically deploying it from an existing S3 bucket to a new AWS Amplify service that it sets up for you.
The repository structure contains:
- examples: this folder contains ready to use examples that show how to use this Module
- tests: this folder contains a list of automated tests for this Module and examples
- lib: this folder contains a list of local utilities, mostly Makefiles, to support the contributor's maintenance effort of this Module
- modules: this folder contains a list of local Terraform modules that the Root Module uses
- .github: this folder contains a list of GitHub workflows to support contributions during change requests and releases of this Module
Documentation about the AWS Amplify service can be found here. Refer to this page for details in regard to contribution instructions.
Module inputs include:
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| awss3bucket_store | The AWS S3 details where the ZIP bundle that needs to be deployed is stored | object | n/a | yes |
| deployment_name | The name of the |
React Project Deployment Workflow
Deploy React on AWS Amplify Using Terraform
Recently, I received a question from a software engineer that I was determined to help solve:
I would like to deploy my AWS Amplify React project using Terraform so that I can automate my workflow and eliminate any manual intervention during deployment.
AWS Amplify can help you build and deploy full-stack applications with ease, while Terraform allows you to define your infrastructure configurations in code using a declarative configuration language.
I will walk through the process I used to achieve this task using Terraform. I will assume that you already have an understanding of using Terraform and AWS.
If you are new to Terraform, Amplify and AWS, there are many valuable resources to get you up to speed including Terraform: Beyond the Basics with AWS and Fullstack TypeScript: Reintroducing AWS Amplify.
Step 1
Step 2
Start the AWS command-line interface running on your workstation so that you can authenticate with AWS.
Step 3
For this tutorial, create a React.js app using the command below
Orchestrating AWS Amplify Deployments with Terraform: Simplifying Scalable Development
OverView :-
AWS Amplify is a powerful tool that can help you build and deploy full-stack applications with ease. Terraform is an infrastructure as code tool that allows you to manage your cloud infrastructure in a declarative manner. In this tutorial, we will show you how to deploy AWS Amplify using Terraform.
Best Practices for Terraform Workspaces
Using Terraform for Amplify gives you a single source of truth for all infrastructure and consistent state management across resources.
The ability to create identical environments with terraform workspace helps maintain dev, staging, and production parity.
Drift detection and automated reconciliation ensure that manual changes made in the Amplify console are identified and corrected by the next Terraform apply.
Integration with your existing CI/CD pipelines allows automated deployments on every push to a connected repository.
Conclusion
Terraform-driven AWS Amplify provisioning closes the gap between managed hosting convenience and enterprise infrastructure as code requirements. By defining awsamplifyapp, awsamplifybranch, and awsamplifydomain_association resources in Terraform, teams gain version control, reproducible environments, and drift detection for Amplify workloads without leaving their existing IaC workflows.
The combination of a provider-driven app definition with build_spec control, GitHub token integration, and S3-backed state provides a complete path from repository to production. Module-based approaches such as the JetBrains terraform-aws-amplify module further accelerate adoption by packaging S3-to-Amplify deployment patterns and tested examples for React and static sites.
For organizations already standardizing on Terraform for VPCs, databases, and other AWS resources, bringing Amplify under Terraform management ensures a unified source of truth, automated reconciliation, and safe, repeatable scaling across workspaces. The result is a fully automated, infrastructure-as-code deployment pipeline for AWS Amplify applications with minimal manual intervention.
Sources
- oneuptime.com/blog/post/2026-02-12-deploy-amplify-backend-resources-with-terraform/view
- mahira-technology.medium.com/deploying-aws-amplify-using-terraform-62be45cd25f2
- plainenglish.io/aws/how-to-setup-aws-amplify-infrastructure-with-terraform
- github.com/JetBrains/terraform-aws-amplify
- thenewstack.io/deploy-an-aws-amplify-react-project-using-terraform/