Carlos Enrique Moreno Alvarez
5 min readMar 26, 2023

Securing Your Application with AWS Edge Services: Which Option is Right for You?

Example diagram

A few days ago i was analyzing a case, about a client who had some needs to maintain control over access to their applications that were exposed with API Gateway but in front they have CloudFront.

In simple terms, both API Endpoint Edge Optimized and CloudFront are AWS services that help accelerate and secure your business applications served with AWS Edge services. However, there are some key differences between the two.

API Endpoint Edge Optimized is primarily designed for APIs that are served through Amazon API Gateway. When you create an API in Amazon API Gateway, you can choose to make it “Edge Optimized”. This means that Amazon will automatically create a CloudFront distribution (managed by AWS) for your API, and route requests to the nearest edge location. This can help reduce latency (in theory) and improve performance for your API users.

On the other hand, CloudFront is a more general-purpose content delivery network (CDN). It can accelerate the delivery of static and dynamic content, including web pages, images, videos, and also APIs. CloudFront can also be used to secure your content with SSL/TLS encryption, and provide protection against common web attacks like DDoS when combined with WAF and Shield.

In terms of performance and security, both API Endpoint Edge Optimized and CloudFront can provide benefits. However, the choice between the two depends on your specific use case. If you are primarily serving APIs through Amazon API Gateway, then API Endpoint Edge Optimized may be the better choice. However, if you have a more general-purpose application with a mix of content types, then CloudFront may be a better fit.

Overall, both API Endpoint Edge Optimized and CloudFront can be powerful tools for accelerating and securing your business applications served with AWS Edge services. It’s important to consider your specific needs and use case when choosing between the two.

CloudFront provides more granular access control features than API Endpoint Edge Optimized.

CloudFront allows you to restrict access to certain elements of your application using various mechanisms, such as IP address whitelisting or blacklisting, signed URLs or cookies, and AWS WAF (Web Application Firewall) rules. You can also use CloudFront with other AWS services, such as AWS Lambda or Amazon S3, to control access to your content at the origin level.

API Endpoint Edge Optimized, on the other hand, provides basic security features such as SSL/TLS encryption and support for OAuth2 authentication. However, it does not offer the same level of granular access control as CloudFront.

Therefore, if you need to restrict access to certain elements of your application in a more controlled manner, CloudFront would be the better choice.

In the case that i was working few days ago a client wanted to restrict an endpoint (URL) of the application to only a group of users who connect via VPN, so what would be the best option of these two services?

Well, In my opinion this brings a dilemma, and does it have to do with the benefit of using CloudFront for connections that terminate in a VPC? However, to restrict an endpoint (URL) of the application to only a group of users who connect via VPN, CloudFront would be the better option.

With CloudFront, you can use various access control mechanisms such as IP address whitelisting or blacklisting, signed URLs or cookies, and AWS WAF rules. In this case, you can use IP address whitelisting to allow access to the endpoint only from the IP addresses associated with the VPN. This will effectively restrict access to the endpoint to only those users who connect via the VPN.

+---------------+         +--------------+         +--------------+
| User |<------->| CloudFront |<------->| Application |
| (VPN client) | | Distribution| | Endpoint |
+---------------+ +--------------+ +--------------+

IP Address Whitelist
+------------------+
| VPN IP Addresses |
+------------------+

On the other hand, API Endpoint Edge Optimized does not have a built-in mechanism to restrict access based on IP address or VPN. While you can use OAuth2 authentication to authenticate users, this will not restrict access to the endpoint based on VPN connection.

                    +---------------+
| API Client |
+---------------+
|
+----------------+
| Amazon API |
| Gateway |
+----------------+
|
+-------------+
| API |
| Endpoint |
+-------------+
|
+-------------+
| OAuth2 |
| Provider |
+-------------+

Therefore, to restrict an endpoint (URL) of the application to only a group of users who connect via VPN, CloudFront with IP address whitelisting would be the better option.

In terms of pricing, for API Endpoint Edge Optimized and CloudFront depends on various factors such as the amount of data transferred, the number of requests, and the location of the end-users. Therefore, the cost-effectiveness of each service depends on the specific use case.

Generally speaking, for APIs that are served through Amazon API Gateway, API Endpoint Edge Optimized may be the more cost-effective option. This is because API Gateway provides a pay-per-use pricing model, where you are charged based on the number of API requests and the amount of data transferred. There are no minimum fees or upfront costs, making it easy to start small and scale as needed.

On the other hand, CloudFront has a more complex pricing model, with charges for data transfer, requests, and edge locations. However, CloudFront provides more granular control over caching and access control, and can be used to accelerate and secure a wide range of content types beyond just APIs.

Ultimately, the choice between API Endpoint Edge Optimized and CloudFront depends on your specific use case, and the factors that are most important to you, such as cost, performance, and security. It’s important to consider all of these factors and compare the pricing for each service to determine which is the most cost-effective for your needs.

I want to invite you to run the following AWS Workshops to get down to work:

Improve Your Architecture With Amazon CloudFront

Build your first CRUD API in 45 minutes or less!

No responses yet