monode-serverless
v0.1.29
Published
This contains some basic libraries for using Mondoe with the serverless framework.
Downloads
6
Readme
Monode Serverless
Monode is an infastructure as code framework for configuring cloud services in a TypeScript project. This libarary in particular provides the nessecary dependencies for a Monode project that exports to a serverless framework based project.
Installation
This library should only be installed using the Monode CLI
Usage
Cloud Components
Cloud components are bundles of cloud resources that work together. For example, if you wanted to define a new cloud component:
- Create a file in your Monode project and name it
<ComponentName>.ts
. - At the top of the file add
import { CloudComponent } from 'monode-serverless';
- Define and export your cloud component instance.
export const ComponentName = CloudComponent.defineNew({...});
The example project contains a more detailed example of an S3 cloud component.
Cloud Component Types
Often multiple cloud components follow the same pattern. In these cases you might want to use a Cloud Component Type.
- Create a file in your Monode project, and name it
<TypeName>.ts
. By convention these files reside under<project-root>/src/cloud-types
. - At the top of the file add
import { CloudComponentType } from 'monode-serverless';
- Export your cloud component type.
export const <TypeName> = CloudComponentType.defineNew({...});
- As part of
CloudComponentType.defineNew
's args, create the function that will be used to define instances of this cloud component type. It should have a look something like this.
defineNew(args: <argtype>) {
return {
cloudFormationExports: {
functions: {
...
},
resources: {
...
},
},
...
}
}
Here, the functions entries will be translated to serverless function enteries, and the resources entries will be translated to serverless/CloudFormation resoruce entries. Feel free to explore the example cloud component types.
Compiling
When you run $ mnd compile
or $ monode compile
in your Monode project, Monode will analyze the cloud componet types and instances, and export their config and code to the sepcified serverless project.
Dependencies
- This library should be installed and compiled using the Monode CLI.
- This library should be used with the serverless framework.