Rewrite Mantle functions to use assets/archives
This commit is contained in:
parent
e97632e668
commit
3849761065
2 changed files with 12 additions and 3 deletions
|
@ -5,3 +5,8 @@
|
|||
export const NodeJS = "nodejs";
|
||||
export const Python = "python";
|
||||
|
||||
export let ext: {[lang: string]: string} = {
|
||||
NodeJS: ".js",
|
||||
Python: ".py",
|
||||
};
|
||||
|
||||
|
|
|
@ -14,10 +14,11 @@ import {asset} from "@coconut/coconut";
|
|||
export class Function {
|
||||
private readonly name: string; // the function name.
|
||||
private readonly runtime: arch.Runtime; // the function's language runtime.
|
||||
private readonly code: asset.Archive; // the function's code archive.
|
||||
private readonly code: asset.Asset; // the function's code.
|
||||
private readonly handler: string; // the function's entrypoint/handler.
|
||||
private readonly resource: any; // the cloud-specific function object.
|
||||
|
||||
constructor(name: string, code: asset.Archive, runtime: arch.Runtime) {
|
||||
constructor(name: string, code: asset.Asset, runtime: arch.Runtime) {
|
||||
this.name = name;
|
||||
this.code = code;
|
||||
this.runtime = runtime;
|
||||
|
@ -57,8 +58,11 @@ export class Function {
|
|||
}
|
||||
|
||||
private initAWSResources(): any {
|
||||
// Generate a thunk that invokes the callback with the right arguments.
|
||||
return new aws.lambda.Function(this.name, {
|
||||
code: this.code,
|
||||
code: new asset.AssetArchive({
|
||||
["index" + arch.runtimes.ext[this.runtime]]: this.code,
|
||||
}),
|
||||
handler: "index.handler",
|
||||
runtime: runtime.aws.getLambdaRuntime(this.runtime),
|
||||
role: runtime.aws.getLambdaRole(),
|
||||
|
|
Loading…
Reference in a new issue