Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Lambda@Edge has to be in us-east-1 region?

I am trying to create a CloudFormation stack in us-east-2 (Ohio) region. However, getting the following error

com.amazonaws.services.cloudfront.model.InvalidLambdaFunctionAssociationException:
The function must be in region 'us-east-1'

I have gone through the below sources and understand that this is a requirement that must be fulfilled by the lambda. My question is why? Why such restriction have been placed? I have looked in the documentations but they only mention the usage of us-east-1 but provide no reasoning!

https://github.com/awslabs/serverless-application-model/issues/635

https://medium.com/@mnylen/lambda-edge-gotchas-and-tips-93083f8b4152

like image 704
cmxiv 914 Avatar asked May 06 '20 13:05

cmxiv 914


People also ask

Is Lambda specific to region?

When working with AWS Lambda functions, the question of region is one of the first you need to answer. As each Lambda function lives in a specific AWS region, and each AWS region has a slightly different set of functionality, you may find yourself having to work with functions in multiple regions on a regular basis.

Why do we need Lambda edge?

Lambda@Edge can help you block unwanted bots at the edge, and let the authorized traffic go through. By intelligently mitigating these automated processes, you can help protect your origin infrastructure from unhelpful web crawlers and bots, while improving performance for real users.

How does the lambda@edge stack work?

The stack utilizes a Lambda@Edge function which checks the country code of an HTTP request and modifies the URI to point to a different index.html object within an S3 bucket. CDNs are ubiquitous. Modern websites and applications make extensive use of CDN technologies to increase speed and reliability.

What are the design limitations of lambda@edge?

Lambda@Edge has some design limitations: Node.JS only, must be deployed through us-east-1, limitations on memory size differ between event types, etc. Read on for a working example alongside tips and outside resources to inform you of key design considerations as you evaluate Lambda@Edge.

How do I publish a new version of lambda@edge?

Since Lambda@Edge requires a specific version to be referenced, you need to instruct Terraform to publish a new version for every change. To do this, use publish = true: The function must be deployed in the us-east-1 region.

How much does lambda@edge cost?

In total, Lambda@Edge is three times as expensive as a normal Lambda. But for simple cases, like transforming a request, the math is a bit different. Lambda@Edge is metered at 50ms increments and if you don’t use any external services then it’s likely you’ll never exceed that. That means for every 1 million requests you’ll pay ~$0.9 extra.


2 Answers

It seems to be an arbitrary decision. Lambda@Edge functions are distributed globally, but they originate from one place. The reason is most likely that there needs to be a single source of truth, and they picked us-east-1. This was also the first region and is special in a few ways (it handles billing, etc). It may have some benefits on their backend that we are not aware of.

like image 84
stefansundin Avatar answered Sep 18 '22 08:09

stefansundin


The reason is because Cloud-front's Control plane is only in us-east-1. i.e. if us-east-1 is down, the ability to update/create distributions is down.

like image 22
hazirovich Avatar answered Sep 19 '22 08:09

hazirovich