Secure and Optimize APIs with Amazon CloudFront Using AWS CLI

Secure and Optimize APIs with Amazon CloudFront Using AWS CLI
Secure and Optimize APIs with Amazon CloudFront Using AWS CLI

CLOUD LABS



Secure and Optimize APIs with Amazon CloudFront Using AWS CLI

In this Cloud Lab, you’ll learn to build a secure serverless Product Catalog API using DynamoDB, Cognito, and API Gateway in AWS CloudShell. You’ll secure endpoints with Cognito, deploy via CloudFront, and add WAF for extra protection.

10 Tasks

intermediate

1hr 30m

Certificate of Completion

Desktop OnlyDevice is not compatible.
No Setup Required
Amazon Web Services

Learning Objectives

Working knowledge of creating and configuring a CloudFront distribution for an API Gateway origin
The ability to manage cache behaviors differently for public and private API endpoints
Hands-on experience integrating AWS WAF with CloudFront to secure API endpoints
Hands-on experience integrating DynamoDB and API Gateway

Technologies
API Gateway logoAPI Gateway
CloudFront
AWS CLI
WAF
Cognito
Cloud Lab Overview

Amazon CloudFront and AWS WAF are often used together to create a powerful security and performance solution for web applications.

Amazon CloudFront, a content delivery network (CDN), is used to enhance website performance by caching content at edge locations worldwide, thereby reducing latency and providing a faster user experience. AWS WAF is a web application firewall that provides an additional layer of security by inspecting web requests at the application level and filtering out malicious traffic before it reaches backend servers. This combination protects against common web exploits, such as SQL injection and cross-site scripting (XSS), ensuring that only legitimate requests are processed by the application. This, in turn, improves its availability and reduces operational costs.

The architecture you’ll provision in this Cloud Lab to demonstrate performance and security enhancements of the API is given below:

Enhancing API performance and security with Amazon CloudFront, AWS WAF, and Amazon Cognito user pools
Enhancing API performance and security with Amazon CloudFront, AWS WAF, and Amazon Cognito user pools

In this Cloud Lab, you’ll build a secure Product Catalog API on AWS by integrating multiple services. You’ll create a DynamoDB table and insert sample product data into it. Next, you’ll configure a Cognito user pool with an app client and domain to handle user authentication.

Using API Gateway, you’ll expose two endpoints:

  • Public: It retrieves all products via a DynamoDB scan and is open to everyone.

  • Private: It retrieves a specific product and is protected with Cognito authentication.

You’ll then deploy the API and expose it with a CloudFront distribution for global and cached access. Finally, you’ll enhance security by attaching AWS WAF with rate-limiting and managed rule sets, then test both public and private endpoints: the former is accessible directly, and the latter requires a Cognito JWT token.

Cloud Lab Tasks
1.Introduction
Getting Started
2.Create the DynamoDB Table API and Its Cognito Authorizer
Create the DynamoDB Table
Create and Configure the Cognito User Pool
Create the Rest API in API Gateway
Create a Private Endpoint and Attach a Cognito Authorizer
3.Enhance API Performance and Security
Set Up CloudFront Distribution
Integrate AWS WAF with CloudFront
Test the Set Up
4.Conclusion
Clean Up
Wrap Up
Labs Rules Apply
Stay within resource usage requirements.
Do not engage in cryptocurrency mining.
Do not engage in or encourage activity that is illegal.
Hear what others have to say
Join 1.4 million developers working at companies like