0.1.2 • Published 6 years ago

serverless-lambda-version v0.1.2

Weekly downloads
91
License
MIT
Repository
github
Last release
6 years ago

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

:exclamation: 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"
            ]
          }
        ]
      ]
    }
  }
],