serverless-plugin-function-value

2.0.12 • Public • Published

Serverless Function Value Plugin

License Version Release Coverage Node Version Serverless Version

Serverless framework plugin that will automatically generate AWS CloudFormation snippets to reference a functions name, ARN or logical ID value based on the internally generated Lambda logical ID. All 2.x versions support only Serverless 3.x. For Serverless 2.x please use the 1.x versions.

Installation

npm i -D serverless-plugin-function-value

Usage

service: test

plugins:
  - serverless-plugin-function-value

provider:
  name: aws
  ...

resources:
  Resources:
    LambdaFunctionExecutor:
        DependsOn:
          - ${fn.logicalid:test}
        Type: Custom::LambdaFunctionExecutor
        Properties:
            ServiceToken: ${fn.arn:test}
            Name: ${fn.name:test}

functions:
  test:
    ...

During processing the ${fn.*} related items will be resolved to either the Fn::GetAtt for ${fn.arn:*}, Ref for ${fn.name:*} or simply the logical ID for ${fn.logicalid:*}. The custom resource above would look like the below in the generated CloudFormation template.

"LambdaFunctionExecutor": {
    "DependsOn": [
      "TestLambdaFunction"
    ],
    "Type": "Custom::LambdaFunctionExecutor",
    "Properties": {
        "ServiceToken": {
            "Fn::GetAtt": [
                "TestLambdaFunction",
                "Arn"
            ]
        },
        "Name": {
            "Ref": "TestLambdaFunction"
        }
    }
}

Development

Development can be done on any machine that can install Node.js. Only the latest LTS version is tested against.

Install Dependencies

Install dependencies via npm.

npm i

Linting

Execute linters via npm.

# git, javascript, markdown and package.json
npm run lint

# git only
npm run lint:git

# javascript only
npm run lint:js

# markdown only
npm run lint:md

# package.json only
npm run lint:pkg

Testing

Execute tests via npm.

# lint, unit tests and integration tests
npm test

# unit tests only
npm run test:unit

# integration tests only
npm run test:integration

Fixing

Execute automatic fixers via npm.

# javascript, markdown and package.json
npm run fix

# javascript only
npm run fix:js

# markdown only
npm run fix:md

# package.json only
npm run fix:pkg

Building

Run a build via npm.

npm run build

Package Sidebar

Install

npm i serverless-plugin-function-value

Weekly Downloads

11

Version

2.0.12

License

MIT

Unpacked Size

12.9 kB

Total Files

4

Last publish

Collaborators

  • devpow112