UNPKG

typed-serverless

Version:

Helps you write a consistent Serverless Framework configuration in TypeScript

29 lines (28 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getServerlessAwsFunctionLogicalId = exports.getServerlessAwsResourceName = void 0; /** * Serverless has a special logical id naming convention for the resources they manage. * So this function converts from our logical ids to the serverless ones. * * @see https://www.serverless.com/framework/docs/providers/aws/guide/resources/#override-aws-cloudformation-resource * @see https://github.com/serverless/serverless/blob/8d56d0e520db8068e89fa8d4d2bf4e64b0acd97b/lib/plugins/aws/lib/naming.js#L583 */ function getServerlessAwsResourceName(resourceName) { const normalizedName = resourceName .replace(/-/g, 'Dash') .replace(/_/g, 'Underscore'); return (normalizedName[0].toUpperCase() + normalizedName.substring(1)); } exports.getServerlessAwsResourceName = getServerlessAwsResourceName; /** * Serverless has a special logical id naming convention for lambdas. * So this function converts from our logical ids to the serverless ones. * * @see https://www.serverless.com/framework/docs/providers/aws/guide/resources/#override-aws-cloudformation-resource * @see https://github.com/serverless/serverless/blob/8d56d0e520db8068e89fa8d4d2bf4e64b0acd97b/lib/plugins/aws/lib/naming.js#L146 */ function getServerlessAwsFunctionLogicalId(id) { return `${getServerlessAwsResourceName(id)}LambdaFunction`; } exports.getServerlessAwsFunctionLogicalId = getServerlessAwsFunctionLogicalId;