Member-only story
Terraform — Setting Up WAF on CloudFront

Setting up a Web Application Firewall (WAF) on Amazon CloudFront using Terraform is a powerful way to protect your web applications from common web exploits and vulnerabilities. AWS WAF helps you monitor HTTP and HTTPS requests, control access based on conditions, and filter out malicious traffic. Terraform, an infrastructure as a code tool, allows you to automate and manage your AWS resources efficiently. This guide will walk you through the steps to set up AWS WAF on CloudFront using Terraform.
Prerequisites
Before starting, ensure you have the following:
- AWS Account: An active AWS account with the necessary permissions.
- AWS CLI: AWS CLI should be configured with your AWS credentials.
- Terraform Installed: Terraform must be installed on your local machine. You can download it from Terraform’s official site.
So, let’s start!
→ Create a “provider.tf”
The provider file tells Terraform which provider you are using.
provider "aws" {
alias = "source"
region = "${var.region}"
profile = "<source-profile-name>"
}