Skip to content

Multiple SAM template function support #18

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

Closed
alteredtech opened this issue Feb 3, 2025 · 1 comment
Closed

Multiple SAM template function support #18

alteredtech opened this issue Feb 3, 2025 · 1 comment

Comments

@alteredtech
Copy link

I was wondering if it is possible for multiple function definitions in the sam template. Currently it seems like it just proxies everything to the server that then does the routing (if my understanding is correct). As I currently understand, the current method would require a different executable defined in the package, which would also mean an openapi.yaml and openapi-generator-config.yaml file for each executable even though they are sharing the same file.

Instead of

Resources:
  # Lambda function
  PetStore:
    Type: AWS::Serverless::Function
    Properties:
      Events:
        # pass through all HTTP verbs and paths
        Api:
          Type: HttpApi
          Properties:
            Path: /{proxy+}
            Method: ANY

To

Resources:
  GetPetbyId:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: <Whatever this would be>
      Events:
        Api:
          Type: HttpApi
          Properties:
            Method: get
            Path: /pet/{petId}
  GetPetsbyTags:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: <Whatever this would be>
      Events:
        Api:
          Type: HttpApi
          Properties:
            Method: get
            Path: /pet/findbytags
  GetPetsbyStatus:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: <Whatever this would be>
      Events:
        Api:
          Type: HttpApi
          Properties:
            Method: get
            Path: /pet/findbyStatus
  UpdatePet:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: <Whatever this would be>
      Events:
        Api:
          Type: HttpApi
          Properties:
            Method: put
            Path: /pet
  AddPet:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: <Whatever this would be>
      Events:
        Api:
          Type: HttpApi
          Properties:
            Method: post
            Path: /pet
@sebsto
Copy link
Collaborator

sebsto commented Mar 7, 2025

Yes, it should work
There is an example in this blog post
https://manuchandrasekhar.medium.com/sam-template-configure-an-api-gateway-with-multiple-lambdas-921b38873389

@sebsto sebsto closed this as completed Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants