UNPKG

@geek-fun/serverlessinsight

Version:

Full life cycle cross providers serverless application management for your fast-growing business.

33 lines (32 loc) 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveFunction = void 0; const common_1 = require("../../common"); const fgsApplication = (context, service) => ` resource "huaweicloud_fgs_application" "${service}_app" { name = "${service}-app" description = "${service} application" package_type = "event" } `; const fgsFunction = (fn, context, service) => ` resource "huaweicloud_fgs_function" "${fn.key}" { name = "${fn.name}" handler = "${fn.code.handler}" runtime = "${fn.code.runtime}" memory_size = ${fn.memory} timeout = ${fn.timeout} environment = ${JSON.stringify(fn.environment)} code_type = "inline" func_code = "${(0, common_1.resolveCode)(fn.code.path)}" app = "huaweicloud_fgs_application.${service}_app.id" } `; const resolveFunction = (stack, functions, context, service) => { if (!functions) { return undefined; } const app = fgsApplication(context, service); stack.appendHcl(app + '\n' + functions.map((fn) => fgsFunction(fn, context, service)).join('\n')); }; exports.resolveFunction = resolveFunction;