serverless-lambda-edge-pre-existing-cloudfront
Advanced tools
Comparing version 1.0.0 to 1.1.0
19
index.js
@@ -18,3 +18,3 @@ 'use strict' | ||
functionObj.events.forEach(async (event) => { | ||
if (event.preExistingCloudFront) { | ||
if (event.preExistingCloudFront && this.checkAllowedDeployStage()) { | ||
const functionArn = await this.getlatestVersionLambdaArn(functionObj.name) | ||
@@ -57,2 +57,19 @@ const config = await this.provider.request('CloudFront', 'getDistribution', { | ||
checkAllowedDeployStage() { | ||
if ( | ||
this.serverless.service.custom && | ||
this.serverless.service.custom.lambdaEdgePreExistingCloudFront && | ||
this.serverless.service.custom.lambdaEdgePreExistingCloudFront.validStages | ||
) { | ||
if ( | ||
this.serverless.service.custom.lambdaEdgePreExistingCloudFront.validStages.indexOf( | ||
this.stage | ||
) < 0 | ||
) { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
async associateNonDefaultCacheBehaviors(cacheBehaviors, event, functionName, functionArn) { | ||
@@ -59,0 +76,0 @@ for (let i = 0; i < cacheBehaviors.Items.length; i++) { |
{ | ||
"name": "serverless-lambda-edge-pre-existing-cloudfront", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "The Serverless Framework plugin which creates Lambda@Edge against pre-existing CloudFront.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# Serverless Lambda Edge PreExisting CloudFront | ||
The Serverless Framework plugin which associates Lambda@Edge against pre-existing CloudFront distribution. | ||
A Serverless Framework plugin which associates Lambda@Edge against pre-existing CloudFront distributions. | ||
@@ -14,3 +14,3 @@ ## Install | ||
Here is configuration in your serverless.yml | ||
Configure serverless.yml | ||
@@ -32,5 +32,15 @@ ```yaml | ||
And run deploy | ||
Run deploy | ||
``` | ||
$ serverless deploy | ||
``` | ||
You can specify additional configurations a `lambdaEdgePreExistingCloudFront` value in the custom section of your serverless.yml file. | ||
A `validStages` value allows you to specify valid stage names for deploy Lambda@Edge. | ||
```yaml | ||
lambdaEdgePreExistingCloudFront: | ||
validStages: | ||
- staging | ||
- production | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9162
157
44