serverless
Version:
Serverless Framework - Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more
20 lines (15 loc) • 697 B
JavaScript
;
const ServerlessError = require('../../../classes/Error').ServerlessError;
function 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 resolveCfImportValue(provider, name, { NextToken: result.NextToken });
}
throw new ServerlessError(
`Could not resolve Fn::ImportValue with name ${name}. Are you sure this value is exported ?`
);
});
}
module.exports = resolveCfImportValue;