/serverless-cfml

Serverless CFML Lambda Functions

Primary LanguageColdFusionMIT LicenseMIT

Serverless CFML Lambda Functions

Standing on the shoulders of the fuseless.org project.

It's primary differences are:

  • Handles multiple serverless applications
  • Uses the Serverless framework rather than SAM
  • Unit tests cfml components
  • Allows local/staging/production deployment configurations

Installation (*nix)

Either run the ./run install script* in your terminal or install manually.

* sudo required

Development

./functions/greeter/Application.cfc

fuselessEvent() is the entry point for invoked Lambda functions

onRequest() is the entry point for Lambda functions called via API gateway

Creating a new Serverless Application

Follow the basic structure of the "greeter" application.

  • Modify:

    • ./functions/yournewapp/cfml/src/Application.cfc
    • ./functions/yournewapp/serverless.yml
    • ./functions/yournewapp/tests/run
    • ./functions/yournewapp/tests/*.cfc
  • Most other cfcs can be removed

Configuration

./functions/greeter/config contains the custom env variables that are available to serverless.yml

./run script

./run help will list the commands available

Testing

Run all tests

cd functions/greeter

./run test

Run tests separately

./run test:serverless

./run test:unit

Run the unit tests in a browser:

cd rocketunit

box server start openbrowser=true --noSaveSettings

Compiling

cd functions/greeter

./run build

This command will compile the cfml templates to bytecode and run the gradle build, resulting in a finished ./build/distributions/greeter.zip file ready to deployment to AWS Lambda.

Deployment

You will need a "serverless" role in AWS IAM that has permission to perform all the resource creation defined in your serverless.yml

See https://www.serverless.com/framework/docs/providers/aws/cli-reference/deploy

Credits

Pull Requests Welcome


Thanks go to the Flying Spaghetti Monster

I am the Flying Spaghetti Monster. Thou shalt have no other monsters before Me (Afterwards is OK; just use protection). The only Monster who deserves capitalization is Me! Other monsters are false monsters, undeserving of capitalization.

-- Suggestions 1:1