I have a lambda which should be invoked from a public URL (through API-Gateway - no authorization needed)
I know I can fetch public URL by calling awsSdk.apiGateway.getApi(apiId)
So I need to get apiId
from somewhere. I've heard that it's possible to fetch api-id
by lambda-name
, but I can't find it in docs.
Is it really possible? the alternative is to keep api-id
in my app's config (instead of lambda-name
)
Just by using a lambda name, you can't get apiId
. Maybe what you heard is that in the lambda you can get the apiId
and then return it to the caller. This would make sense as apiId
is part of the event object that API gateway passes to the lambda function with each request.
To get the apiId
from lambda name only, you would have to develop your own custom solution for that. This would still be problematic, because a single lambda can be associated with multiple APIs, thus you would probably have to account for that as well.
The simplest way to develop such a solution would be to store associations between APIs and its lambda functions in, e.g. DynamoDB table, and query the table when needed to get the apiId
based on lambda name only.