Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

New agent implementation to support FAAS on AWS Lambda based on the node v8 engine.

Support Model

...

Pre Requisites

AWS lambda functions are small and short pieces of code that is invoked by calling to an http endpoint.

...

Code Block
npx slnodejs config --tokenfile sltoken.txt --appName "AWS Lambda" --branch "master" --build 3
npx slnodejs scan --workspacepath ./src --tokenfile sltoken.txt --buildsessionidfile buildSessionId --scm none --awsConfigure
npx slnodejs start --tokenfile sltoken.txt --buildsessionidfile buildSessionId --teststage "Sealights on Lambda"

...

Code Block
service: aws-node-http-api-project

provider:
  name: aws
  vpc:
    securityGroupIds:
      - sg-965602ef
    subnetIds:
      - subnet-028c8368058b24e21
  region: eu-west-1
  runtime: nodejs16.x

functions:
  api-normal:
    handler: ./src/test-lambda-1/index.handler
    events:
      - httpApi:
          path: /default
          method: get
# START - SL addition
    layers:
      - arn:aws:lambda:eu-west-1:159616352881:layer:sl-nodejs-layer:44
# END - SL addition

resources:
  Resources:
    MyLambdaExecutionRole:
      Type: AWS::IAM::Role
      Properties:
        RoleName: MyLambdaExecutionRole
        AssumeRolePolicyDocument:
          Version: '2012-10-17'
          Statement:
            - Effect: Allow
              Principal:
                Service: lambda.amazonaws.com
              Action: sts:AssumeRole
        Policies:
          - PolicyName: LambdaVPCAccessPolicy
            PolicyDocument:
              Version: '2012-10-17'
              Statement:
                - Effect: Allow
                  Action:
                    - logs:CreateLogStream
                    - logs:CreateLogGroup
                    - logs:TagResource
                  Resource:
                    - "arn:aws:logs:eu-west-1:534369319675:log-group:/aws/lambda/aws-node-http-api-project-dev*:*"
                - Effect: Allow
                  Action:
                    - logs:PutLogEvents
                  Resource:
                    - "arn:aws:logs:eu-west-1:534369319675:log-group:/aws/lambda/aws-node-http-api-project-dev*:*"
                - Effect: Allow
                  Action:
                    - lambda:InvokeFunction
                  Resource: "*"
                - Effect: Allow
                  Action:
                    - ec2:CreateNetworkInterface
                  Resource: "*"

Special Considerations

Support for Additional Layers:

  • Currently, using other layers with SeaLights layer is supported only for:

    • Dynatrace (AWS_LAMBDA_EXEC_WRAPPER=/opt/dynatrace)

    • OTEL (AWS_LAMBDA_EXEC_WRAPPER:/opt/otel-handler)

  • If you are using the Dynatrace or OTEL handlers, the SL layer will automatically detect this and work with it.

  • When you do not want SeaLights Lambda Layer to run OTEL layer, you must explicitly disable it with DISABLE_OTEL_HANDLER=true

  • When you do not want SeaLights Lambda Layer to run Dynatrace layer, you must explicitly disable it with DISABLE_OTEL_HANDLER=true