silvermine / serverless-plugin-cloudfront-lambda-edge

Adds Lambda@Edge support to Serverless
MIT License
296 stars 41 forks source link

Set region for edge function #80

Closed mstruensee closed 2 years ago

mstruensee commented 2 years ago

In production we deploy to us-west-2 but one of the limitations to using lambdas at the edge is they must be deployed to us-east-1 ...

how can this plugin accept a region as a param so we do not get this error during deployment ...

Resource handler returned message: "Invalid request provided: The function must be in region 'us-east-1'. ARN: arn:aws:lambda:us-west-2:165158022346:function:prod-radar360-edge:1 (Service: CloudFront, Status Code: 400, Request ID: 3f26f79a-e78a-4cf9-8ad3-77cc2fabf714)" (RequestToken: 8d30bd73-2edb-86fe-d89d-7c3d571cf092, HandlerErrorCode: InvalidRequest)

is there a way i can reference a cdn in an external/different stack?

jthomerson commented 2 years ago

@mstruensee what you request isn't possible. There's several similar (closed) issues in our tracker here that you can look at if you want more details on why. Put simply, this plugin simply adjusts your CloudFormation template to configure your L@E, so we can't do what you're asking. If you want to use L@E, you have to deploy to us-east-1, as the error explains.

mstruensee commented 2 years ago

what about .... is there a way i can reference a cdn in an external/different stack?

looked at the code you grab the resources by the string name to get like 3 variables ... could it be possible to grab that from cf?

jthomerson commented 2 years ago

@mstruensee no. CloudFormation does not support us deploying a L@E function except as part of the deployment of the CloudFront distribution it will be used with. This is a CloudFront / CloudFormation problem - not a problem with the plugin.

mstruensee commented 2 years ago

thanks for clearing that up!