Closed AllegraChen closed 4 years ago
We use the "serverless-plugin-ifelse" to define if the lambda@edge should be deployed or not and yaml logic to define the distribution IDs:
custom:
cloudFrontDistIds:
dev: xxx
prod: yyy
cloudFrontDistId: ${self:custom.cloudFrontDistIds.${self:custom.stage}, self:custom.cloudFrontDistIds.dev}
...
serverlessIfElse:
- If: '"${self:custom.stage}" != "${self:custom.resourcesStage}"'
Exclude:
- functions.lambdaEdgeTest
Hi @jonasbarsten, thank you for your solution. That is a very interesting way of solving this problem! I would definitely use that if-else plugin next time if needed.
However, I think that this serverless-lambda-edge-pre-existing-cloudfront
plugin would be more powerful and easier to use with this feature. As your solution suggests, we need to depend on another plugin. Besides, we need to write some more code by using the if-else plugin whereas the configuration for my solution is simpler, easier to understand, and easier to maintain.
Therefore, I would suggest @horike37 to add that feature in. :)
Yeah, makes sense 👍
I hope to deploy to different existing CloudFront distributions based on different stages. However, this plugin does not seem to provide me with that extra layer of functionality. The
validStages
property that we can configure at thecustom
section does not do the work since we are not able to set thevalidStages
property for eachpreExistingCloudFront
object.Therefore, I was thinking that I could open a pull request to add that extra feature. I hope that we could have a
stage
property for eachpreExistingCloudFront
object under theevent
array like this:See detailed implementation in PR #15