serverless-lambda-edge-pre-existing-cloudfront
Advanced tools
Comparing version 1.1.5 to 1.2.0
30
index.js
@@ -26,3 +26,2 @@ 'use strict' | ||
) | ||
for (let idx = 0; idx < events.length; idx += 1) { | ||
@@ -35,5 +34,8 @@ const event = events[idx] | ||
const functionArn = await this.getlatestVersionLambdaArn(functionObj.name) | ||
const resolvedDistributionId = await (event.preExistingCloudFront.distributionId['Fn::ImportValue'] | ||
? this.resolveCfImportValue(this.provider, event.preExistingCloudFront.distributionId['Fn::ImportValue']) | ||
: event.preExistingCloudFront.distributionId | ||
) | ||
this.serverless.cli.consoleLog( | ||
`${functionArn} is associating to ${event.preExistingCloudFront.distributionId} CloudFront Distribution. waiting for deployed status.` | ||
`${functionArn} (Event: ${event.preExistingCloudFront.eventType}, pathPattern: ${event.preExistingCloudFront.pathPattern}) is associating to ${resolvedDistributionId} CloudFront Distribution. waiting for deployed status.` | ||
) | ||
@@ -45,3 +47,3 @@ | ||
const config = await this.provider.request('CloudFront', 'getDistribution', { | ||
Id: event.preExistingCloudFront.distributionId | ||
Id: resolvedDistributionId | ||
}) | ||
@@ -67,3 +69,3 @@ | ||
.request('CloudFront', 'updateDistribution', { | ||
Id: event.preExistingCloudFront.distributionId, | ||
Id: resolvedDistributionId, | ||
IfMatch: config.ETag, | ||
@@ -113,3 +115,5 @@ DistributionConfig: config.DistributionConfig | ||
properties: { | ||
distributionId: { type: 'string' }, | ||
distributionId: { | ||
anyOf: [{ type: 'string' }, { type: 'object' }], | ||
}, | ||
eventType: { type: 'string' }, | ||
@@ -191,3 +195,17 @@ pathPattern: { type: 'string' }, | ||
} | ||
resolveCfImportValue(provider, name, sdkParams = {}) { | ||
return provider.request('CloudFormation', 'listExports', sdkParams).then(result => { | ||
const targetExportMeta = result.Exports.find(exportMeta => exportMeta.Name === name); | ||
if (targetExportMeta) return targetExportMeta.Value; | ||
if (result.NextToken) { | ||
return this.resolveCfImportValue(provider, name, { NextToken: result.NextToken }); | ||
} | ||
throw new Error( | ||
`Could not resolve Fn::ImportValue with name ${name}. Are you sure this value is exported ?` | ||
); | ||
}); | ||
} | ||
} | ||
module.exports = ServerlessLambdaEdgePreExistingCloudFront |
{ | ||
"name": "serverless-lambda-edge-pre-existing-cloudfront", | ||
"version": "1.1.5", | ||
"version": "1.2.0", | ||
"description": "The Serverless Framework plugin which creates Lambda@Edge against pre-existing CloudFront.", | ||
"main": "index.js", | ||
"author": "serverless-operations", | ||
"repository": "serverless-operations/serverless-lambda-edge-pre-existing-cloudfront", | ||
"license": "MIT", | ||
@@ -8,0 +9,0 @@ "scripts": { |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
13560
230