Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge API entity into one package #100

Open
ianpogi5 opened this issue Apr 22, 2021 · 0 comments
Open

Merge API entity into one package #100

ianpogi5 opened this issue Apr 22, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@ianpogi5
Copy link
Member

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.
@ianpogi5 ianpogi5 added the enhancement New feature or request label Apr 22, 2021
@ianpogi5 ianpogi5 added this to the Beta 1 milestone Apr 22, 2021
@ianpogi5 ianpogi5 self-assigned this Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant