UNPKG

serverless

Version:

Serverless Framework - Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more

28 lines (23 loc) 941 B
'use strict'; const ServerlessError = require('../../../classes/Error').ServerlessError; function resolveCfRefValue(provider, resourceLogicalId, sdkParams = {}) { return provider .request( 'CloudFormation', 'listStackResources', Object.assign(sdkParams, { StackName: provider.naming.getStackName() }) ) .then((result) => { const targetStackResource = result.StackResourceSummaries.find( (stackResource) => stackResource.LogicalResourceId === resourceLogicalId ); if (targetStackResource) return targetStackResource.PhysicalResourceId; if (result.NextToken) { return resolveCfRefValue(provider, resourceLogicalId, { NextToken: result.NextToken }); } throw new ServerlessError( `Could not resolve Ref with name ${resourceLogicalId}. Are you sure this value matches one resource logical ID ?` ); }); } module.exports = resolveCfRefValue;