I'm using AWS CDK to create my cloud stacks, I've identified that the error "this.combinedGrant is not a function" is being produced by the following code but I can't find any references to it:
let authFunctions = [
{
name: 'user-registration',
handler: 'index.register',
code: './handlers/user-registration',
loginAccess: loginTable.grantFullAccess,
otpAccess: otpTable.grantWriteData
},
...
for (let i in authFunctions) {
let definition = authFunctions[i];
let func = new Function(this, `${definition.name}-function`, {
runtime: Runtime.NODEJS_12_X,
handler: definition.handler,
code: Code.asset(definition.code),
environment: {
LOGIN_TABLE_NAME: loginTable.tableName,
OTP_TABLE_NAME: otpTable.tableName,
MAILGUN_DOMAIN: credentials.mailgun.domain,
MAILGUN_FROM: credentials.mailgun.from,
MAILGUN_API_KEY: credentials.mailgun.api_key,
JWT_SECRET: definition.hasJWTSecret ? "secret-placeholder" : ""
},
layers: [authLayer, utilityLayer],
timeout: Duration.seconds(5)
});
definition.loginAccess(func);
definition.otpAccess(func);
let api = new RestApi(this, `${definition.name}-api`);
api.root.addMethod('POST', new LambdaIntegration(func));
}
The problem was in attempting to assign
loginTable.grantFullAccessfunctions directly. The solution was to replace with a string and then use switch cases to apply them:...