Skip to content

Instantly share code, notes, and snippets.

View carlholloway's full-sized avatar

Carl Holloway carlholloway

View GitHub Profile
@jeshan
jeshan / get-lambda-event-source.js
Last active June 23, 2023 13:01
AWS Lambda: Determine Event Source from event object. Note that this is an approximation as anybody can send a payload that resembles the real thing.
function getLambdaEventSource(event) {
if (event.Records && event.Records[0].cf) return 'isCloudfront';
if (event.configRuleId && event.configRuleName && event.configRuleArn) return 'isAwsConfig';
if (event.Records && (event.Records[0].eventSource === 'aws:codecommit')) return 'isCodeCommit';
if (event.authorizationToken === "incoming-client-token") return 'isApiGatewayAuthorizer';
if (event.StackId && event.RequestType && event.ResourceType) return 'isCloudFormation';

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@moea
moea / nginx.config
Created February 11, 2016 11:30
Place in .ebextensions to increase Nginx timeout in a non-Docker AWS Elastic Beanstalk Worker Environment
files:
"/tmp/proxy.conf":
mode: "000644"
owner: root
group: root
content: |
proxy_send_timeout 1200;
proxy_read_timeout 1200;
send_timeout 1200;
@muratcorlu
muratcorlu / grunt-connect-rewrite.js
Last active May 14, 2016 01:29
Simple connect middleware for simulating url-rewriting for grunt connect servers.
var fs = require('fs'),
url = require('url');
module.exports = function (rootDir, indexFile) {
indexFile = indexFile || "index.html";
return function(req, res, next){
var path = url.parse(req.url).pathname;
fs.readFile('./' + rootDir + path, function(err, buf){
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"