Skip to content

⚡ 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

License

Notifications You must be signed in to change notification settings

devpow112/serverless-plugin-function-value

Repository files navigation

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

About

⚡ 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

Topics

Resources

License

Security policy

Stars

Watchers

Forks