WAF and CloudFront


AWS Web Application Firewall
AWS Shield
Start course
4h 44m

This course looks at the key Security services within AWS relevant to the SysOps Administrator - Associate exam. The core to security is Identity & Access Management, commonly referred to as IAM. This service manages identities and their permissions that are able to access your AWS resources and so understanding how this service works and what you can do with it will help you to maintain a secure AWS environment.  In addition to IAM, this course covers a range of other security services covering encryption and access control

Learning Objectives

  • Learn about identity and access management on AWS including users, groups & roles, IAM policies, MFA, and cross-account access
  • Learn the fundamentals of AWS Web Application Firewall (WAF) including what it is, when to use it, how it works, and why use it
  • Learn how to manage data protection through encryption services such as the Key Management Service (KMS) and CloudHSM
  • Learn how to secure your AWS accounts using AWS Organizations
  • Understand how to configure and monitor AWS WAF, Firewall Manager, and Shield
  • Learn the fundamentals of access control via federation using AWS Cognito and AWS SSO

Hello and welcome to this lecture on how AWS WAF and AWS CloudFront can work together. As a prerequisite of this lecture, you should have a basic understanding of AWS CloudFront. More information on CloudFront can be found here from our existing course. AWS WAF relies heavily on AWS CloudFront distributions. However, it's worth mentioning that this service dependency relationship is only one way, meaning that AWS CloudFront can operate and exist without AWS WAF being configured. AWS WAF also supports custom origins, allowing you to apply the same level of security to web infrastructure managed outside of AWS. As we saw in the demonstration earlier, the final step of configuring the service is to associate your Web ACL to an AWS CloudFront distribution. When this association between the two services takes place, it can take approximately 15 minutes for the Web ACL and associated rules to be propagated to all relevant Edge locations linked with your CloudFront distribution. This propagation is automatically instigated by CloudFront. 

By propagating this configuration out to the Edge locations, it helps to ensure performance is maintained and latency kept low by not having to perform these WAF checks at another location in an availability zone somewhere else across the world. When a request is blocked by WAF, CloudFront is notified that the request was forbidden and CloudFront will return a 403 error to their browser. This is a standard error code when access to a HTTP resource is forbidden. Now this error doesn't really provide much information to the end user, and offers no reason as to why the error was generated. All in all, it can be a bit frustrating for the end user. And so you can create your own custom 403 errors, and it's far is more professional, and you can guide the user to other useful links and provide a polite reason as to why they may have experienced the error. 

This creates a better user experience despite the user not being able to access the resource they were after. The next time a user is blocked by WAF, CloudFront would then display the custom error code instead. For more information on this customization, please see the following link. Before working on your Web ACLs, look at the CloudFront distribution that you intend on associating the Web ACL to. The reason being is that when you are creating your CloudFront distributions, you can select what HTTP methods that AWS CloudFront will respond to, and which ones it will not. Therefore, it would be inefficient to configure conditions that blocked against HTTP methods that would be dropped by CloudFront anyway. Instead, use a combination of the two, CloudFront configuration and WAF Web ACLs to process incoming requests effectively. When creating your CloudFront distributions, you have an option during step two, Create Distribution, to select an existing AWS WAF Web ACL so you don't have to associate your Web ACLs through AWS WAF. You can also change your Web ACL from within the AWS CloudFront console as well by selecting your distribution and clicking on Edit under the General tab. From there, you can then select a different AWS WAF Web ACL. That brings me to the end of this lecture. Coming up next, I'll be talking about the pricing options for this service.

About the Author
Learning Paths

Stuart has been working within the IT industry for two decades covering a huge range of topic areas and technologies, from data center and network infrastructure design, to cloud architecture and implementation.

To date, Stuart has created 150+ courses relating to Cloud reaching over 180,000 students, mostly within the AWS category and with a heavy focus on security and compliance.

Stuart is a member of the AWS Community Builders Program for his contributions towards AWS.

He is AWS certified and accredited in addition to being a published author covering topics across the AWS landscape.

In January 2016 Stuart was awarded ‘Expert of the Year Award 2015’ from Experts Exchange for his knowledge share within cloud services to the community.

Stuart enjoys writing about cloud technologies and you will find many of his articles within our blog pages.