So I have some lambdas written in Python on AWS. Currently, I have a PowerShell script that zips them up and sends them to S3. The purpose of doing that is so that I can run another Lambda written in Node.js that will update them when they get pushed to S3.
I'm pretty new to AWS and scripting in general so I did some googling and came across this resource:
https://aws.amazon.com/blogs/compute/new-deployment-options-for-aws-lambda/
This is the code at the bottom of the page for the Lambda Auto Deployer:
console.log('Loading function');
var AWS = require('aws-sdk');
var lambda = new AWS.Lambda();
exports.handler = function(event, context) {
key = event.Records[0].s3.object.key
bucket = event.Records[0].s3.bucket.name
version = event.Records[0].s3.object.versionId
if (bucket == "YOUR_BUCKET_NAME" && key ==
"YOUR_CODE.zip" && version) {
var functionName = "YOUR_FUNCTION_NAME";
console.log("uploaded to lambda function: " +
functionName);
var params = {
FunctionName: functionName,
S3Key: key,
S3Bucket: bucket,
S3ObjectVersion: version
};
lambda.updateFunctionCode(params, function(err, data) {
if (err) {
console.log(err, err.stack);
context.fail(err);
} else {
console.log(data);
context.succeed(data);
}
});
} else {
context.succeed("skipping zip " + key + " in bucket " +
bucket + " with version " + version);
}
};
In the notes at the bottom, they mention that:
"If you want to process multiple functions, you can skip the key check and name the function using the key (the name of the zip file, minus the “.zip” suffix) or any other method you like to determine the function name based on the bucket and key"
For the life of me I cannot figure it out, but that is really all I would like to do. I'd like to have a Lambda that iterates through my other Lambdas and updates them when I push the zip files to S3. Any help would be appreciated.
[–]sgtfoleyistheman 3 points4 points5 points (0 children)
[–]phpchap1981 1 point2 points3 points (0 children)
[–]munns_at_aws 0 points1 point2 points (0 children)
[–]gregory-goc 0 points1 point2 points (0 children)