holy-lambda

Benjamin 2021-10-25T09:22:41.008300Z

what is a good way to implement multiple endpoints? When I call the lambda with the url like https//aws.my-thing/foo does the foo appear somewhere? I can also make it depend on the headers or content or sth

Karol Wójcik 2021-10-25T09:29:49.008600Z

There are two approaches. 1. One lambda per one endpoint 2. One lambda for multiple endpoints. At Retailic we're using the second approach, where we have an integration between regular ring/muuntaja stack and holy-lambda. But if you don't want to use ring, then just print the event. All the necessary properties are there. To use HL with multiple endpoints specify a proxy+ in template.yml like so:

RetailicFabloApiLambdaFunction:
    Type: AWS::Serverless::Function
    Properties:
      Policies:
        - Version: "2012-10-17"
          Statement:
          - Effect: "Allow"
            Action:
              - "ec2:CreateNetworkInterface"
              - "ec2:DeleteNetworkInterface"
              - "ec2:DescribeNetworkInterfaces"
              - "ec2:DetachNetworkInterface"
            Resource: "*"
        - Version: "2012-10-17"
          Statement:
          - Effect: "Allow"
            Action:
              - "rds-db:connect"
            Resource:
              - !Ref RDSConnectionIAMARN
      VpcConfig:
        SecurityGroupIds: !Ref SecurityGroupIds
        SubnetIds: !Ref PrivateSubnetIds
      Environment:
        Variables:
          DATABASE_URL: !Ref DatabaseConnectionURL
          PUBLIC_URL: !Sub "https://${DomainName}"
          FRONTEND_URL: !Ref FrontendURL
      FunctionName: !Sub "RetailicFabloApiLambdaFunction-${Environment}"
      PackageType: Image
      ImageUri: !Ref ImageUri
      Events:
        HttpProxyEvent:
          Type: HttpApi
          Properties:
            ApiId: !Ref RetailicHttpApi
            Path: /{proxy+}
            Method: ANY

Karol Wójcik 2021-10-25T09:30:06.008800Z

You need just proxy+ 🙂

Benjamin 2021-10-25T09:38:03.009Z

cool will check. Btw what is a good way to test without using aws sam? Like the -main function get's called I guess with some payload

Karol Wójcik 2021-10-25T10:03:08.009200Z

You mean unit tests or just making sure it will work on AWS as well?

Karol Wójcik 2021-10-25T10:03:52.009400Z

or like you're looking for something like regular ring server that you can span, kill, restart at any time etc?

steveb8n 2021-10-25T10:58:53.009700Z

This works for me https://github.com/FieryCod/holy-lambda/tree/master/examples/bb/native/aws-interop-v2.example

❤️ 1
Benjamin 2021-10-25T11:36:44.009900Z

Don't mean unit tests, but simulating the way aws is calling the program + having it running in the repl @steveb8n example seems to do that; Will check it out. For my usecase I just need 1 example input data kinda then build the flesh of my program.