silvermine / serverless-plugin-cloudfront-lambda-edge

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

Support for CloudFormation Condition #28

Open iDVB opened 5 years ago

iDVB commented 5 years ago

Any change we can add support for CFN condition? Something like...

lambdaAtEdge:
  - distribution: WebsiteDistribution
    eventType: origin-response
    condition: isDev
...
Conditions:
    isDev: {"Fn::Equals" : ["${self:custom.vars.STAGE}", "dev"]}

so that when the function is created it will place that condition on the Association and the function itself.

I'm happy to put a PR in if that sounds good.

jthomerson commented 5 years ago

Hmmm. I struggle to see why someone would want to deploy one stage differently - especially without the function or its association - than other stages. But, that's probably my OCD - I want absolute parity between dev, qa, prd. I'd like to hear more about your usecase.

All that said, I'm not fundamentally against adding this support if you wanted to submit a PR and have some easy-to-understand usecase. In your PR don't forget to update the docs (README) accordingly.

iDVB commented 5 years ago

@jthomerson Well the question is larger. Why would anyone want to use CFN conditions at all? The reason we use them is to do things like

Some of our applications are 99% frontend JS, HTML, CSS hosted statically. so 99% of what needs to be tested is the visual site itself. We sometimes use a CDN in prod for these to handle the URL rewrites for the routes.

Since provisioning a CDN takes 30mins+ we decided to go with Speed over Parity. We can deploy a site without a CDN in 2mins. This makes deploying feat-* branch tests VERY fast.

The parity comes later in the pipe before prod.

jthomerson commented 5 years ago

Thanks for the clear explanation. Looking forward to the PR

tibraga commented 3 years ago

Any news?