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. Combining the two provides a reproducible, version-controlled path to provision Amplify apps, branches, domain associations, webhooks, and related backend resources using Terraform.
AWS Amplify is a managed service for typical fullstack applications, allowing developers to connect their Git repository and manage automatic deployments of their app frontends, backend APIs, authentication, storage, serverless functions, etc. It is AWS’ answer to Netlify, Vercel, Cloudflare kickstarter app deploys, and so abstracts away the underlying infrastructure and how it connects together for a simpler GUI and code-driven configuration.
For enterprise teams, managing Amplify separately creates a gap in your infrastructure-as-code strategy. If your organization already uses Terraform for VPCs, databases, and other AWS resources, managing Amplify separately creates a gap. 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.
Why Terraform for Amplify
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
Terraform enables you to automate the provision and management of your AWS Amplify resources. Once you have defined your changes in the declarative configuration language, Terraform will apply the changes automatically, reducing any manual or human intervention.
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.
Prerequisites and Initial Setup
Prerequisites:
- 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 minimum supported Terraform version is 1.3.0.
Step 1: Install Terraform and the AWS CLI
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.
From the AWS console, set up an IAM user with the policy AdministratorAccess-Amplify to manage your Terraform infrastructure.
Step 2: Project Structure
To deploy with AWS Amplify via Terraform within a monorepo structure:
.
├── frontend
│ ├── package.json
│ └── ...
└── infra
├── main.tf
└── ...
For this tutorial, create a React.js app using the command below.
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.
Core Terraform Configuration for Amplify
Configure the AWS Provider first.
```hcl
providers.tf - AWS provider configuration
terraform {
requiredversion = ">= 1.0"
requiredproviders {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
Use S3 backend for state management
backend "s3" {
bucket = "my-terraform-state"
key = "amplify/terraform.tfstate"
region = "us-east-1"
}
}
provider "aws" {
region = var.aws_region
}
```
Create a folder named amplify in your home directory. With in the amplify folder create a file named main.tf.
The service provides a unified model to manage backend and frontend development workflows, and it helps to seamlessly integrate with other AWS services.
Amplify App Resource
The awsamplifyapp resource creates the Amplify application:
```hcl
amplify.tf - Main Amplify app configuration
resource "awsamplifyapp" "main" {
name = var.appname
repository = var.repositoryurl
GitHub personal access token for repository access
accesstoken = var.githubaccess_token
Build specification
buildspec = <<-EOT
version: 1
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: .next
files:
- '/*'
cache:
paths:
- nodemodules//*
EOT
Environment variables
}
```
Step 2: Create the Amplify App Resource
The awsamplifyapp resource creates the Amplify application.
The file should include the following code:
hcl
resource "aws_amplify_app" "amplify_app" {
name = var.app_name
repository = var.repository
oauth_token = var.token
}
Amplify Branch Resource
hcl
resource "aws_amplify_branch" "amplify_branch" {
app_id = aws_amplify_app.amplify_app.id
branch_name = var.branch_name
}
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.
Domain Association
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.
| Name | Version | |||
|---|---|---|---|---|
| terraform | >= 1.3 | |||
| aws | >= 5.20 | |||
| Name | Version | |||
| --- | --- | |||
| aws | >= 5.20 | |||
| Name | Type | |||
| --- | --- | |||
| awsamplifyapp.site | resource | |||
| awsamplifybranch.site | resource | |||
| 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 |
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.
Deploying a React Project End-to-End
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.
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.
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.
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.
Since AWS Amplify serves basic accelerated app deployments its Terraform support is in less demand which likely explains some long-standing bugs which I’ve circumvented and documented here.
Module-Based Approach
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 minimum supported Terraform version is: 1.3.0.
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.
Comparison of Resource Patterns
| Resource | Purpose | Key Arguments |
|---|---|---|
| awsamplifyapp | Creates Amplify application | name, repository, accesstoken, buildspec |
| awsamplifybranch | Links branch to app | appid, branchname |
| awsamplifydomain_association | Maps custom domain | appid, domainname, sub_domain |
Using Terraform for Amplify gives you a single source of truth for all infrastructure and consistent state management across resources.
Conclusion
Deploying AWS Amplify with Terraform shifts Amplify from an interactive console workflow to a fully declarative, version-controlled pipeline. The approach centralizes app, branch, and domain definitions in code, enabling reproducible environments, drift detection, and automated reconciliation across development, staging, and production.
The core pattern remains the awsamplifyapp resource with repository connection and build specification, paired with awsamplifybranch for environment mapping and awsamplifydomainassociation for custom domain routing. Provider configuration with S3 backend state management ensures team-safe collaboration, while variables for appname, repositoryurl, githubaccesstoken, branchname, and domain_name keep secrets and naming out of source.
Despite less demand for Amplify Terraform support, the benefits for enterprise teams are clear: a single source of truth for all infrastructure, consistent state management, and integration with existing CI/CD pipelines. For teams already operating with Terraform for VPCs, databases, and other AWS resources, managing Amplify through Terraform closes the infrastructure-as-code gap and makes the entire stack auditable and repeatable.
Module-based patterns such as terraform-aws-amplify further simplify adoption by automating S3-to-Amplify deployments and providing tested examples, with minimum requirements of Terraform >= 1.3.0 and AWS provider >= 5.20. The combination of Amplify’s managed hosting experience with Terraform’s declarative control delivers a scalable development model where frontend code changes trigger automated Amplify deployments while infrastructure remains locked to code.
Sources
- https://mahira-technology.medium.com/deploying-aws-amplify-using-terraform-62be45cd25f2
- https://tobiasedwards.co.uk/blog/deploying-aws-amplify-with-terraform/
- https://oneuptime.com/blog/post/2026-02-12-deploy-amplify-backend-resources-with-terraform/view
- https://plainenglish.io/aws/how-to-setup-aws-amplify-infrastructure-with-terraform
- https://thenewstack.io/deploy-an-aws-amplify-react-project-using-terraform/
- https://github.com/JetBrains/terraform-aws-amplify