Closed romanfq closed 3 years ago
Hi, @romanfq
I am unassigning and marking this issue as p2
, which means that we are unable to work on this immediately.
We use +1s to help prioritize our work, and are happy to revaluate this issue based on community feedback. You can reach out to the cdk.dev community on Slack to solicit support for reprioritization.
@romanfq I'm surprised you can't just run
const alias = ...
api.addLambdaDataSource('LambdaDataSource', alias);
addLambdaDataSource
takes IFunction
as the property type which Version
and Alias
extend from...
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.
Allow a Lambda Data Source that can point to an alias
Use Case
When using Provisioned Concurrency today in a Lambda- for lower cold-starts- an alias gets created, which is usually called
live
. The ARN of this alias is that of the Lambda Function with a:live
suffix.Now, when a lambda data source is added to an AppSync API, the data source is pointing to the Lambda function and not the the alias, and then calls from AppSync don't call the alias but the $LATEST version of the function (no idea why this doesn't work). This defeats Provisioned Concurrency.
There's a manual workaround: after deploying the AppSync API and the Lambda, you can go to the console and
Proposed Solution
Add native support to the CDK to generate an Alias datasource, similar to
or simply add an override to
addLambdaDataSource
that allows to supply an aliasI tried to simulate the same by creating my own types under the DataSource hierarchies (i.e. creating a new sub-type of
BackedDataSource
and forcing agrantInvoke
on the IAM role for the alias but it didn't work well- I might post repro code at some later stage.This is a :rocket: Feature Request