Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

388
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda