serverless-lambda-edge-pre-existing-cloudfront
Advanced tools
Comparing version 1.1.0 to 1.1.1
32
index.js
@@ -14,7 +14,17 @@ 'use strict' | ||
'after:aws:deploy:finalize:cleanup': async () => { | ||
this.serverless.service.getAllFunctions().forEach(async (functionName) => { | ||
const functionObj = this.serverless.service.getFunction(functionName) | ||
if (functionObj.events) { | ||
functionObj.events.forEach(async (event) => { | ||
if (event.preExistingCloudFront && this.checkAllowedDeployStage()) { | ||
await this.serverless.service | ||
.getAllFunctions() | ||
.filter((functionName) => { | ||
const functionObj = this.serverless.service.getFunction(functionName) | ||
return functionObj.events | ||
}) | ||
.reduce((promiseOutput, functionName) => { | ||
return promiseOutput.then(async () => { | ||
const functionObj = this.serverless.service.getFunction(functionName) | ||
const events = functionObj.events.filter( | ||
(event) => event.preExistingCloudFront && this.checkAllowedDeployStage() | ||
) | ||
for (let idx = 0; idx < events.length; idx += 1) { | ||
const event = events[idx] | ||
const functionArn = await this.getlatestVersionLambdaArn(functionObj.name) | ||
@@ -41,3 +51,7 @@ const config = await this.provider.request('CloudFront', 'getDistribution', { | ||
this.provider.request('CloudFront', 'updateDistribution', { | ||
this.serverless.cli.consoleLog( | ||
`${functionArn} is associating to ${event.preExistingCloudFront.distributionId} CloudFront Distribution. waiting for deployed status.` | ||
) | ||
await this.provider.request('CloudFront', 'updateDistribution', { | ||
Id: event.preExistingCloudFront.distributionId, | ||
@@ -47,9 +61,5 @@ IfMatch: config.ETag, | ||
}) | ||
this.serverless.cli.consoleLog( | ||
`${functionArn} is associating to ${event.preExistingCloudFront.distributionId} CloudFront Distribution. waiting for deployed status.` | ||
) | ||
} | ||
}) | ||
} | ||
}) | ||
}, Promise.resolve()) | ||
} | ||
@@ -56,0 +66,0 @@ } |
{ | ||
"name": "serverless-lambda-edge-pre-existing-cloudfront", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "The Serverless Framework plugin which creates Lambda@Edge against pre-existing CloudFront.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
9533
165