Patrick Gold
10/21/2021, 11:44 PMgrantDataApiAccess()
to an RDS Serverless Cluster. It looks like the type signature for the return value of api.getFunction()
(Fn | undefined
) doesn’t match what grantDataApiAccess
is looking for (IGrantable
). Has anybody encountered this issue before? Thanks for the help!
Code:
cluster.grantDataApiAccess(api.getFunction('GET /test'));
Error:
Argument of type 'Function | undefined' is not assignable to parameter of type 'IGrantable'.
Type 'undefined' is not assignable to type 'IGrantable'.ts(2345)
thdxr
10/21/2021, 11:45 PMthdxr
10/21/2021, 11:45 PMcluster.grantDataApiAccess(api.getFunction('GET /test')!);
thdxr
10/21/2021, 11:45 PMPatrick Gold
10/21/2021, 11:48 PMthdxr
10/21/2021, 11:55 PMPatrick Gold
10/21/2021, 11:57 PMPatrick Gold
10/21/2021, 11:58 PM// Grant access to the cluster from the Lambda function
const clusterAccessRoutes = ["GET /test"];
clusterAccessRoutes.forEach(route => {
const fnHandler = api.getFunction(route);
if (fnHandler) {
cluster.grantDataApiAccess(fnHandler);
}
});