serverless-lambda-version

0.1.2 • Public • Published

serverless-lambda-version

Serverless License NPM Build Status Contributors

A Serverless v1.x plugin to auto update lambda function version for Lambda@Edge LambdaFunctionAssociations.

Amazon recently added a requirement to LambdaFunctionAssociations, where you can no longer reference the arn+alias(or $LATEST) and are now required to provide arn+version. This plugin handles appending on the version for you. You just need to set your LambdaFunctionARNs equal to the logicalID string and the plugin will take care of the rest.

Install

$ npm install serverless-lambda-version --save-dev

Add the plugin to your serverless.yml file:

plugins:
  - serverless-lambda-version

Usage

Set your yml references LambdaFunctionAssociations[n].LambdaFunctionARN equal to the logicalID of your function.

functions:
  myfunction:
    handler: functions/myfunction/handler.myfunctionHandler
 
resources:
  Resources:
  CDN:
    Type: "AWS::CloudFront::Distribution"
    Properties:
      DistributionConfig:
        ...
        DefaultCacheBehavior:
          ...
          LambdaFunctionAssociations:
            EventType: origin-request
              LambdaFunctionARN: MyfunctionLambdaFunction

❗️ Any LambdaFunctionARNs already set to arn+version should be ignored by the plugin.

Cloudformation Output:

"LambdaFunctionAssociations"[
  {
    "EventType": "origin-request",
    "LambdaFunctionARN": {
      "Fn::Join": [
        "",
        [
          {
            "Fn::GetAtt": [
              "MyfunctionLambdaFunction",
              "Arn"
            ]
          },
          ":",
          {
            "Fn::GetAtt": [
              "MyfunctionLambdaFunctionOZWEIGtTFB4RTIGbHCEthNMa97ZkMRinlERrCc0",
              "Version"
            ]
          }
        ]
      ]
    }
  }
],

Package Sidebar

Install

npm i serverless-lambda-version

Weekly Downloads

104

Version

0.1.2

License

MIT

Last publish

Collaborators

  • idvb