aws / chalice

Python Serverless Microframework for AWS
Apache License 2.0
10.6k stars 1.01k forks source link

How to configure several projects to use a single API #513

Open pyvotal-cguers opened 7 years ago

pyvotal-cguers commented 7 years ago

We are working on a large sized API with several resources and methods. In order to keep the size of the resulting Lambda function small, we want to break the overall API into smaller [Chalice] projects, but they are all part of the same API. Is there a way to configure each Chalice project to be part of a single API?

API
  /resource1/* -> maps to Chalice project 1
  /resource2/* -> maps to Chalice project 2

We are currently developing directly in Lambda and mapping the Lambda functions to each resource/method in the API. It would help us tremendously to use Chalice instead, but performance and cost are a key factor.

Thanks!

JordonPhillips commented 7 years ago

Chalice currently doesn't support automatically setting your custom domain. AFAIK apigateway will only partially allow having multiple apis under one domain. You would need to have each api be under a different path (e.g. example.com/api1 and example.com/api2).

libert-xyz commented 7 years ago

I have the same question, @JordonPhillips the question is referred to mapping multiple Chalice Projects to a single API Gateway. Like a Microservice architecture.

Ex.

GET
https://url-api.us-east-1.amazonaws.com/api/products/{id} --> Maps to Chalice Project Products
https://url-api.us-east-1.amazonaws.com/api/clients/{id} --> Maps to Chalice Project Clients
pyvotal-cguers commented 7 years ago

Correct, @rschmidtz. The idea is that (following your example) ../products/{id} could be pretty big on its own, so it would be more efficient to have only that code in an app. This way, when a user calls .../clients/{id}, only that code is called on by API+Lambda and not everything else. This would keep memory consumption and latency under control.

If this is not possible today (from all the reading the testing I have been doing, it seems it is not), this would be a great new feature.

JordonPhillips commented 7 years ago

@pyvotal-cguers That sort of setup should be possible. Right now you would need to manually configure your api, but if we support custom domains then that setup shouldn't be too hard. Getting the auto domain support may be tricky though, especially for domains not registered via route53.

kadrach commented 6 years ago

I'd be very interested in this as well.

Currently looking at using the package output and nested CF stacks to add Route53 entries, but orchestration as a whole is still a bit of an unknown for us.

nplutt commented 6 years ago

Hey @JordonPhillips,

I have a proposal for this feature. I think it would be easiest to break this work out into two features, the first being the ability to create a custom domain name, and the second being the ability to setup route53 entries for either an api gateway or a custom domain. This proposal will only cover the ability to create and configure custom domains.

The inputs that would be needed from a user would be:

When a user deploys the following workflow would happen:

  1. If the custom domain doesn't exist then then it is created using the domain name and cert arn
  2. The app is deployed and the api gateway is created
  3. If the specified base path mapping doesn't exist then it is setup to point at the newly created api gateway

Let me know what you think! Also how would you like the inputs from the user to be handled? I think the inputs should come from a config file, but if you think differently let me know.

gimbel0893 commented 6 years ago

+1 Ability to have multiple chalice projects deploy to 1 API Gateway as microservices would be great. Right now you can manipulate deployed.json to deploy to the same gateway, but the swagger uploads will overwrite existing endpoints.

A workaround we're trying today is to have a CloudFront distribution route to different gateways. Still thinking about how auth will work across them. We're session based backed by Dynamo, so might just work out naturally.

dejonghe commented 6 years ago

We need this as well. Need to have a single uniform API endpoint for multiple microservices.

luisdemarchi commented 6 years ago

This issue is old, but I have this problem today. Has anyone got a solution? Have multiple projects on a single gateway API

dmcnally-aam commented 6 years ago

Yep, this is still a real need... really reduces the utility of Chalice for any serious API development.

jglesner commented 5 years ago

+1 We either need a way to have multiple Lambdas in a chalice project #229 or to associate multiple chalice projects to a single API. Specifically for using a single custom domain name for routing purposes and minimizing complexity in CI/CD.

stealthycoin commented 5 years ago

It seems more people want this feature than have thumbed up the initial comment, we use that to sort feature requests so can you please thumbs up the original comment if this is a feature you want.

mims92 commented 5 years ago

+1 While I want somethine like @rschmidtz explained, I was wondering how to test this locally? I have two chalice projects, but I need to start them independently to specify a different port. Is there a solution for that?

kalpaitch commented 4 years ago

For me this is a key make or break feature, I don't think we're going to be able to work chalice into our orchestration flow without it.

rubemlrm commented 7 months ago

Hello, what it's the current status of this proposal? I saw the other proposal issue but both have had no feedback for almost 4 years. I'm analyzing this tool and looks like an amazing tool to be used, but this caveat of having several endpoints in the same lambda function worries me.

Thanks in advance for feedback