Skip to content
Introduces additional Fn:: functions
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples feat: first working version Apr 30, 2019
.editorconfig feat: first working version Apr 30, 2019
.eslintignore feat: first working version Apr 30, 2019
.eslintrc feat: first working version Apr 30, 2019
.gitignore feat: first working version Apr 30, 2019
LICENSE
README.md updated README Apr 30, 2019
commitlint.config.js feat: first working version Apr 30, 2019
index.js
index.test.js feat: first working version Apr 30, 2019
jest.config.js feat: first working version Apr 30, 2019
package-lock.json chore: added semantic-release Apr 30, 2019
package.json

README.md

serverless-plugin-extrinsic-functions

Introduces additional Fn:: functions such as Fn::StartsWith.

Install

Run npm install in your Serverless project.

$ npm install --save-dev serverless-plugin-extrinsic-functions

Add the plugin to your serverless.yml file

plugins:
  - serverless-plugin-extrinsic-functions

How to use

This plugin lets you use a number of custom Fn:: functions in the serverless.yml file. For example, you can use it as part of CloudFormation Conditions:

resources:
  Conditions:
    StartsWithDev:
      Fn::StartsWith: [ dev-yan, dev ]

You can also use it elsewhere in your serverless.yml as well, such as in the custom clause many plugins rely on, or as part of your function definitions:

functions:
  hello:
    handler: handler.hello
    environment:
      STARTS_WITH_DEV:
        Fn::StartsWith: [ dev-yan, dev ]  # use in functions

These are the functions that are current supported, and the javascript functions they map to:

  • Fn::StartsWith: ([ input, prefix ]) => input.startsWith(prefix)
  • Fn::EndsWith: ([ input, suffix ]) => input.endsWith(suffix)
  • Fn::Substr: ([ input, from, length ]) => input.substr(from, length)
  • Fn::Substring: ([ input, start, end ]) => input.substring(start, end)
  • Fn::RandomNumber: ([ min, max ]) => Math.random() * (max - min) + min
  • Fn::GreaterThan: ([ x, y ]) => x > y
  • Fn::LessThan: ([ x, y ]) => x < y
  • Fn::Max: ([ x, y ]) => Math.max(x, y)
  • Fn::Min: ([ x, y ]) => Math.min(x, y)
You can’t perform that action at this time.