Skip to content

Instantly share code, notes, and snippets.

View marcelpanse's full-sized avatar

Marcel Panse marcelpanse

View GitHub Profile
module.exports = function (grunt) {
grunt.initConfig({
lambda_invoke: {
default: {
options: {
// Task-specific options go here.
file_name: "UpdateAccount.js"
}
}
<h1 class=”main-headline” data-txt=”homepage.headline” />
service: Instant
provider:
name: aws
runtime: nodejs4.3
stage: prod
region: eu-west-1
iamRoleARN: arn:aws:iam::XXXXXXXXXXX:role/Lambda-execution
package:
/* // call this from your package.json like:
"scripts": {
"build-static": "webpack && node lib/build-static.js"
}
*/
var shell = require('shelljs')
shell.cp('-f', 'app/index.html', 'build/public/index.html')
// load this script first: <script src="https://apis.google.com/js/api.js?onload=init"></script>
gapi.load('auth2', function() {
googleAuth = gapi.auth2.init({client_id: '<your-google-api-key>.apps.googleusercontent.com'})
googleAuth.signIn({'scope': 'profile email'})
})
// this is a-sync, you should wait till you get the googleAuth object before continueing.
AWS.config.region = 'eu-west-1'
var request = require("request");
var readJSON = require("read-json");
var writeFile = require("write");
var googleIdToken = require("google-id-token");
function getGoogleCerts(kid, callback) {
console.log("Checking cache for google certs");
readJSON("/tmp/certs.json", function(error, cert){
if (error) {
console.log("Cert not found, downloading from google");
var docClient = new DOC.DynamoDB();
var params = {};
params.TableName = "accounts";
params.Key = {accountId: event.accountId};
params.AttributeUpdates = {
website: {PUT: "update", Value: event.website}
};
docClient.updateItem(params, function (err, data) {
if (err) {
console.log(err, err.stack);
'use strict';
var AWS = require("aws-sdk"); //load any NPM dependency
console.log('Loading function');
exports.handler = (event, context, callback) => {
//console.log('Received event:', JSON.stringify(event, null, 2));
console.log('value1 =', event.key1);
console.log('value2 =', event.key2);
console.log('value3 =', event.key3);