I have a lambda, written in Node. I need to make a call to the get_api_key
function from the boto3 library. A stripped down version of my Node.js Lambda function is here:
exports.handler = function(input, context) {
const spawn = require("child_process").spawn;
const pythonProcess = spawn('python',["pythonScript.py", "API_KEY_123"]);
pythonProcess.stdout.on('data', (data) => {
console.log("DATA FROM PYTHON: ", data);
});
};
I used the functionality for this from this question. My Python script looks like this:
import sys
import boto3
#this is the client
client = boto3.client('apigateway')
apiKey = client.get_api_key(apiKey=sys.argv[1], includeValue=True)
print(apiKey)
I expected to see the console.log
result appear in my CloudWatch logs for this Lambda function but it seems we aren't getting any data from the Python script as no logging is done.
Am I doing what I am trying to do correctly? There is a setting on the Lambda function which says that it is written in Node.js so I don't know if the fact that I have randomly made a Python script in the same directory as the Lambda function will be causing a problem?
I am happy for an alternative to this if it might be easier.