Skip to content

Merge API entity into one package #100

@ianpogi5

Description

@ianpogi5

Motivation: As of writing, abu-api- will consume 199 resources. Since the limit is 200, the user cannot create more API endpoints.

Proposed Solution: Merge API entity into one lambda function.

A new file src/index.js will be the one to route to the individual functions.

function.yml

admin-access:
  handler: src/index.handler
  events:
    - http:
        path: /
        method: post
        authorizer:
          type: COGNITO_USER_POOLS
          authorizerId:
            Ref: ApiGatewayAuthorizer
        cors: true
    - http:
        path: /{id}
        method: get
        authorizer:
          type: COGNITO_USER_POOLS
          authorizerId:
            Ref: ApiGatewayAuthorizer
        cors: true
    - http:
        path: /
        method: get
        authorizer:
          type: COGNITO_USER_POOLS
          authorizerId:
            Ref: ApiGatewayAuthorizer
        cors: true
    - http:
        path: /{id}
        method: put
        authorizer:
          type: COGNITO_USER_POOLS
          authorizerId:
            Ref: ApiGatewayAuthorizer
        cors: true
    - http:
        path: /{id}
        method: patch
        authorizer:
          type: COGNITO_USER_POOLS
          authorizerId:
            Ref: ApiGatewayAuthorizer
        cors: true
    - http:
        path: /{id}
        method: delete
        authorizer:
          type: COGNITO_USER_POOLS
          authorizerId:
            Ref: ApiGatewayAuthorizer
        cors: true

Pros:

  • Use only 1 lambda instead of multiple thus reducing the resources.
  • Because we'll be using one lambda for list and CRUD, the lambda maybe kept warm while user is using the endpoint.

Cons:

  • Code is bigger because all operations are inside.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions