developmentseed / cogeo-mosaic-tiler

Serve Map tile from Cloud Optimized GeoTIFF mosaics.
MIT License
12 stars 6 forks source link

HTTP API Gateway #1

Closed kylebarron closed 4 years ago

kylebarron commented 4 years ago

In December, AWS announced HTTP API Gateway endpoints, which appear to be 70% cheaper than the existing REST endpoint type and slightly faster.

I was wondering if there was a specific reason you use the REST endpoint type instead of the newer HTTP type in your serverless.yml?

It looks like you can use HTTP in serverless.yml with the httpApi key. The full spec appears to be here. It looks like the syntax is slightly different than the http key. I tried it out for a couple endpoints successfully, but some internal paths get messed up, like trying to load /docs gives an error:

Failed to load API definition:
undefined /docs/docs/openapi.json
vincentsarago commented 4 years ago

oh that's interesting, I didn't know about it.

Failed to load API definition: undefined /docs/docs/openapi.json

Yeah this must be a lambda-proxy https://github.com/vincentsarago/lambda-proxy issue

Not sure if I'll have time to look at this right now sadly

kylebarron commented 4 years ago

No rush, this just seemed like something that might be worth checking out eventually.

Similar to the /docs endpoint, when loading the tileJSON at

https://naip-lambda.kylebarron.dev/4c4d507790e8afa837215677bd6f74f58711bfaf3e1d5f7226193e12/tilejson.json

its tiles key was

https://naip-lambda.kylebarron.dev/4c4d507790e8afa837215677bd6f74f58711bfaf3e1d5f7226193e12/tilejson.json/4c4d507790e8afa837215677bd6f74f58711bfaf3e1d5f7226193e12/{z}/{x}/{y}@1x

i.e. relative path was made to the tileJSON, not to the root path. I reverted to the REST endpoint, which is working fine. I don't understand API Gateway well enough now to know what's wrong, but it seems like a few changes would need to be made to support the HTTP endpoint in the future.

vincentsarago commented 4 years ago

yeah the whole API gateway URL stuff is a 🕳 . But I'll have a look later for sure

kylebarron commented 4 years ago

Unless you have an objection, we could set the default endpoint to use the HTTP API instead of the REST API. I don't think there's a downside unless you used a type of identity verification