I currently have an api called “cms-api”, which contains a dynamodb scan function in it.
getOrganization.js
'use strict'
const AWS = require('aws-sdk');
exports.handler = async function (event, context, callback) {
const documentClient = new AWS.DynamoDB.DocumentClient();
let responseBody = "";
const params = {
TableName : "Organization"
};
try{
const data = await documentClient.scan(params).promise();
}catch(err){
responseBody = `Unable to get Organization: ${err}`;
}
}
“Organization” Table has below attributes
------------------------------------------
Id isActive name
1 true tim
2 false tom
3 true ken
4 true joe
------------------------------------------
Later, I create another api in api gateway called web-api,
I want to use the same lambda function getOrganization.js in my resource.
But the getOrganization.js should only return the data with isActive = true.
Is it possible? Or should I create a new lambda function every time?
Attached my consideration before.
should I create Public api based on the current internal api