aws-samples / aws-cdk-amplify-with-waf

enable WAF for Amplify Hosted web applications
MIT No Attribution
30 stars 18 forks source link
amplify aws-cdk-python aws-wafv2 security

Enable WAF for Amplify Hosted web applications

Many AWS Amplify Web Applications do not have a firewall attached at all, simply because the integration with AWS WAF does not exist natively. Thus, this template can be a quick and effective way to improve the security of your web application.

Following the steps in this pattern will allow users to create an Amazon CloudFront Distribution associated with an AWS WAFv2 WebACL configured with basic AWS Managed Rulesets. It will also demonstrate how an extra layer of security can be applied to the AWS Amplify application to stop users from circumventing the AWS WAFv2 configuration. All traffic into the application must now go through the new Amazon CloudFront Distribution.

The pattern is supplied with a self-contained sample CDK construct which can be used as-is or modified to enable WAF integration on an existing Amplify web application. The code also enables automated cache invalidation of the newly created CloudFront distribution every time new code is deployed for the Amplify-hosted Web App.

Prerequisites


Limitations


Architecture


Target architecture

Deploying the supplied CDK code will deploy the architecture seen below into the target AWS account. The Amplify Application is not created by the CDK code and is expected to pre-exist within the target AWS account.

Deploying an AWS WAF using the supplied CDK code is optional, you can integrate an existing WAF as long as its attachable to a CloudFront distribution.

Architecture Diagram

Target technology stack

This pattern provides deployment through AWS CDK which can easily be automated in CI/CD pipelines.

Note : The deployment of this CDK code adds configuration to existing Amplify App. This should not create issues for the IaC operations performed on the Amplify resource outside this stack.

Tools


Deployment Steps


Follow below steps to enable WAF on existing Amplify Application using AWS CDK constructs

References

Contributing Guide


Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to integrate your changes in this repository

Code of Conduct


License


This library is licensed under the MIT-0 License. See the LICENSE file.