chalice icon indicating copy to clipboard operation
chalice copied to clipboard

How to configure several projects to use a single API

Open pyvotal-cguers opened this issue 7 years ago • 15 comments

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!

pyvotal-cguers avatar Sep 02 '17 20:09 pyvotal-cguers

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).

JordonPhillips avatar Sep 05 '17 23:09 JordonPhillips

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

libert-xyz avatar Sep 06 '17 00:09 libert-xyz

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.

pyvotal-cguers avatar Sep 06 '17 02:09 pyvotal-cguers

@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.

JordonPhillips avatar Sep 07 '17 23:09 JordonPhillips

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.

kadrach avatar Nov 13 '17 01:11 kadrach

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:

  • domain name
  • cert arn
  • base path for the chalice app

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.

nplutt avatar Dec 11 '17 05:12 nplutt

+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.

gimbel0893 avatar May 11 '18 15:05 gimbel0893

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

dejonghe avatar May 11 '18 16:05 dejonghe

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

luisdemarchi avatar Aug 08 '18 18:08 luisdemarchi

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

dmcnally-aam avatar Aug 23 '18 22:08 dmcnally-aam

+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.

jglesner avatar Jan 09 '19 20:01 jglesner

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.

stealthycoin avatar Aug 15 '19 17:08 stealthycoin

+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?

mims92 avatar Aug 18 '19 19:08 mims92

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.

kalpaitch avatar Aug 31 '20 12:08 kalpaitch

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

rubemlrm avatar Feb 07 '24 15:02 rubemlrm