-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lambda@Edge example only works on us-east-1 region #635
Comments
I'm planning to solve that Issue via an CloundFormation custom resource which deployes that lambda to the other region, but it would be nice if SAM Transforme will so that out of the box for us. |
@timoschilling do you have some code tho share? I'm interested |
@timoschilling how do you make you custom resource work with something like Should we try to directly use |
Sorry at the moment I only have the concept, will share it if its done. |
Ok.. you can share the detailed concept if you want 😉 I was thinking about the following concept (quite hacky but well...): In a single AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Distribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
DefaultCacheBehavior:
LambdaFunctionAssociations:
- EventType: origin-request
LambdaFunctionARN: !Ref LambdaFunctionStandard.Version
# Unused Lambda function only to get `CodeUri` working
LambdaFunctionCodeProxy:
Type: AWS::Serverless::Function
Properties:
CodeUri: src
AutoPublishAlias: live
# Custom resource to "copy" the Lambda in the standard region (us-east-1)
LambdaFunctionStandard:
Type: Custom::LambdaEdgeCopy
Properties:
ServiceToken: !ImportValue CustomRessourceLambdaEdgeCopy
Parameters:
Version: !Ref LambdaFunctionCodeProxy.Version
Region: us-east-1 Something awesome and more simple could be AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Distribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
DefaultCacheBehavior:
LambdaFunctionAssociations:
- EventType: origin-request
LambdaFunctionARN: !Ref LambdaFunction.Version
LambdaFunction:
Type: Custom::LambdaEdgeCopy
Properties:
ServiceToken: !ImportValue CustomRessourceLambdaEdgeCopy
Parameters:
CodeUri: src # Unfortunately `CodeUri` is not processed by SAM for Custom resources Unfortunately |
I am facing same issue |
@anhtv08 My team is using the technique described here #635 (comment) for a whole year and everything is going well. The technique consists (within a single CloudFormation template) of deploying a classic Lambda function on the region of your choice + deploying a custom resource that "copies" the Lambda in Edit: I've shared my solution in a repo -> https://github.com/yvele/aws-cfn-custom-resource-lambda-edge 🚀 |
@yvele could you create a repo, please? |
@yvele I'm also interested in seeing a repo / example of the method as I'm facing the same issue. |
@yvele for me very interesting too how CustomRessourceLambdaEdgeCopy originaly work. |
@yvele could you please share or create a repo ? |
@yvele please create and share a repo with the code example. I am facing this same issue and would love to see a solution. |
In case it's useful for others, we published a blog post and GitHub repo showing how to build and deploy a Lambda@Edge app. Note that under the covers it works by using a CFN Custom Resource that invokes a Lambda Function (Stackery provides this for you, but you can create your own) to create the Edge Lambda Function. (Full disclosure, I'm the CTO @ Stackery. But you can use our free tier if you just want help building your app. You can decide afterwards if you want to pay for us to help you with centralized deployment and management of multiple apps built by teams of developers.) |
Same error here @yvele will traffic shifting still works with your method? |
@yvele could you possibly share your |
Okay I've adapted my code to be open source 😅 I made a repository https://github.com/yvele/aws-cfn-custom-resource-lambda-edge that deploys a CloudFormation custom resource allowing to deploy Lambda@Edge on any other region. The custom resource "copies" the Lambda from your region to us-east-1 allowing to bind it to a CloudFront event via Lambda@Edge. Please fill an issue in the repository if you have any problem or question. I hope AWS CloudFormation (or SAM) will support Lambda@Edge deployment on other regions than us-east-1.
Yep 👍
I'm not using |
The linked example repo no longer works... |
What kind of error do you have? 🤔 Do not hesitate to fill an issue here https://github.com/yvele/aws-cfn-custom-resource-lambda-edge/issues |
@yvele that link works, but the link on the description of the issue shows this, might be just a typo? |
Nope... the AWS team just changed the URL to the example 🤷 nothing I can do.. |
This is not something SAM can directly help with. SAM transforms a SAM Spec into raw CloudFormation. A stack is deployed to a specific region within an account, so once SAM transforms the spec CloudFormation and Service restrictions are in play. Since this is a restriction on the service, SAM can't do anything. There are solutions here to that use a custom resource, which would be a way forward. I would encourage creating forum requests or reach out to your account managers to request Lambda@Edge to support more than Closing |
I'm unable to use the Lambda@Edge example with CloudFront being set on an other region than
us-east-1
.Because a Lambda@Edge function must be in region
us-east-1
:Can you please add a Lambda@Edge example workaround, or recommendations that allows CloudFront and Lambda@Edge to be set up on different regions?
Maybe 2 separate Cloudformation templates?
This issue is related to #323 and #565
PS: Other people on Twitter also expresses this needs
Edit: Workaround here #635 (comment)
The text was updated successfully, but these errors were encountered: