silvermine / serverless-plugin-cloudfront-lambda-edge

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

Existing distributions #58

Closed fusionbeam closed 3 years ago

fusionbeam commented 4 years ago

Hi, Does this plugin work with existing distributions? If so, how should the yml definition look like?

Thanks, R

jthomerson commented 3 years ago

This is a plugin for the Serverless Framework. If you have a CloudFront distribution in a Serverless stack, you can use this plugin to add Lambda@Edge functions to that stack, using the examples in the README.

fusionbeam commented 3 years ago

thank you for answering and the plugin. I'm using it so far to upload the function and then I associate it by hand. (https://forum.serverless.com/t/lambda-edge-with-an-existing-cloudfront-distirbution/9969/3)

in README.md it specifies that there must be a Resource for defining the CloudFront distribution. I don't want to define it and respecify all the parameters in the example. All I need is to refer to it by Arn or Id. Is that supported?

fusionbeam commented 3 years ago

I can see the appeal of creating and defining the CloudFront distributions with Yaml. In my current use case I cannot afford to re-create the distro, DNS re-aliasing would take too much time.

jthomerson commented 3 years ago

We can not implement what you requested. This plugin works with a CloudFormation template (under the Serverless framework). The only way to associate a Lambda@Edge function with a CloudFront distribution is by editing the CloudFront distribution resource itself, which means the CloudFront distribution must be in the CloudFormation template.

You could look at using the CloudFormation support for importing manually-created resources to see if you could get the CloudFront distribution into a Serverless stack ... I haven't done that, and helping with that is beyond the scope of this plugin. If you're able to get the CloudFront distribution imported into a Serverless stack, then you can use this plugin.