Skip to content

Instantly share code, notes, and snippets.

@juancabrera
Created November 17, 2016 21:06
Show Gist options
  • Save juancabrera/51b03a6481818e68dce65aab2f699d5a to your computer and use it in GitHub Desktop.
Save juancabrera/51b03a6481818e68dce65aab2f699d5a to your computer and use it in GitHub Desktop.
Deploy a Node Lambda function
// deploy.js
// how to: http://code.juan.me/how-to-deploy-a-node-lambda-function/
//
const AWS = require('aws-sdk')
const fs = require('fs')
AWS.config.update({region: 'us-east-1'})
const lambda = new AWS.Lambda()
const lambdaFunctionName = 'yourFunctionName'
fs.readFile("./fn.zip", (err, data) => {
if (err) throw err
lambda.updateFunctionCode({
FunctionName: lambdaFunctionName,
ZipFile: data,
Publish: true
}, err => {
if (err) {
console.log('ERROR: ', err)
} else {
console.log('uploaded!')
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment