aws-lambda-ws-server
aws-lambda-ws-server copied to clipboard
postToConnection can't sign custom domain names
Hi,
I'm trying to use your ws server for a project where I have a custom domain name attached to the API Gateway.
In aws-post-to-connection, an aws4 signed URL is created from the domainName in the context. This works fine if my API url is something like xxxxx.execute-api.my-region.amazonaws.com
, but in my case domainName gets set to api.mydomain.com
. This makes the call fail (InvalidTokenException, or similar).
I tried adding URL mappings for my stage, so that api.mydomain.com/prod
maps to the prod stage, but that doesn't seem to help. The only way I can get it to work is to inject the "real" API url as an ENV variable, and change your code that sets the host to
host: process.env.API_URL || domainName
Is there any way to add support for custom domain names? I'm not 100% sure what's needed to make this work, but currently I have to modify the package code to get this to work properly. Any pointers appreciated.
At the time I wrote this this aws-sdk shipped with lambda didn't include the management api for api gateway 2
Maybe we should remove it, the code uses another function when not run in a lambda.
I don't have time myself at the moment, but if you sent a pull request I will check it out when I have time.