Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

360
Vistas
One Lambda Function OR Multiple Lambda Functions

Can I write one Lambda Function to Handle Multiple REST API Requests. I have my data in Dynamo DB

Flow: API Gateway-->Lambda Function-->Dynamo DB Example:

Request1:GET Method-Need to pull data from Table1
/device/{device_id}/start/{start_date}/end/{end_date}/events


Request2:GET Method-Need to pull data from Table2
/device/{device_id}/start/{start_date}/end/{end_date}/event_count

Request3:POST Method-Need to put data from Table3
/device/{device_id}/start/{start_date}/end/{end_date}/fault_events

What is the best solution should I write 3 different lambda functions to handle 3 different requests or can I handle all the 3 requests in one BIG Lambda Function.

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Yes, you can have one Lambda function that handle more than one API. The question is why?

Doing this is considered (almost) an anti-pattern as you won't be able to scale independently the various scenario.

These are two slides from the link pasted above from Chris Munns talk at last re:invent and I strongly agree.

enter image description here enter image description here

over 4 years ago · Santiago Trujillo Denunciar

0

While I don't know enough about your use case to recommend using 1 or multiple Lambda, I can explain one way of working with all queries inside one function.

You can pass in parameters from the lambda event, which come from the AWS API parameters and then use these to determine following logic. An example would look like this -

def lambda_handler(event, context):
    try:
        type_query = str(event['queryStringParameters']['type_query'])
        if type_query == 'x':
            ...do the things
        elif type_query == 'y':
            ...do the other things
        elif type_query == 'z':
            ...do the 3rd thing
    except:
        return {
            'body': "Invalid Params"
        }

Hope this helps!

over 4 years ago · Santiago Trujillo Denunciar

0

You have to find the right balance based on what your application/service does. In general I like to break things down into pretty small pieces, but you need to be careful you aren't going too far, and creating nano-services, which many consider an anti-pattern due to the maintenance overhead you end up creating.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda