Skip to content

Instantly share code, notes, and snippets.

View cerdman's full-sized avatar

colin b. erdman cerdman

  • TriNetX Inc.
  • United States
View GitHub Profile

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.
@dkarchmer
dkarchmer / cognito-developer-authenticated-client-example.py
Last active October 11, 2024 16:44
django-boto3-cognito: AWS' Cognito Developer Authenticated Identities Authflow using Django/Python/Boto3 (For building stand-alone clients)
__author__ = 'dkarchmer'
'''
This script emulates a stand-alone Python based client. It relies on Boto3 to access AWS, but
requires your Django server to have an API for your user to access Cognito based credentials
Because of Cognito, the client (this script) will only get temporary AWS credentials associated
to your user and only your user, and based on whatever you configure your AIM Policy to be.
Most Cognito examples demonstrate how to use Cognito for Mobile Apps, so this scripts demonstrate
how to create a stand-alone Python script but operating similarly to these apps.
# coding: utf-8
# In[ ]:
# https://gist.github.com/DavidJFelix/113fad6a0a7affdd880d
import redis
# In[2]:
@cerdman
cerdman / authentication.py
Created September 23, 2015 15:29 — forked from WayneSan/authentication.py
PyJWT + Django REST framework 2
import jwt
from django.conf import settings
from django.contrib.auth.models import User
from rest_framework import exceptions
from rest_framework.authentication import TokenAuthentication
class JSONWebTokenAuthentication(TokenAuthentication):
@mmohiudd
mmohiudd / gist:1c04702b965d309c2027
Created February 10, 2015 17:33
redis mass insertion
The text file data.txt contains the following
ZADD myzset 1 a
ZADD myzset 1 b
ZADD myzset 1 c
Run this command to read from data file and insert to redis:
cat data.txt|xargs -n 4 redis-cli
#!/bin/bash
# This script checked on CM5.2.1 and CDH5.2.1
# Properties
CMNODE="node1.cloudera.com"
TARGET="node1.cloudera.com node2.cloudera.com node3.cloudera.com"
CLUSTER="Cluster1"
ROOT_PASS="cloudera"
BASE=http://$CMNODE:7180/api/v8
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title>Directives</title>
</head>
<body>
<div ng-controller="ChildController as child">
<button type="button" ng-click="child.sayMe()">Say me!</button>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.1/angular.min.js"></script>
@NotSqrt
NotSqrt / settings_test_snippet.py
Last active May 1, 2022 01:34 — forked from nealtodd/settings_test_snippet.py
Another shot at this problem ..
class DisableMigrations(object):
def __contains__(self, item):
return True
def __getitem__(self, item):
return "notmigrations"
MIGRATION_MODULES = DisableMigrations()
FROM ubuntu:12.04
MAINTAINER Sergey Melnik "smelnik@onetwotrip.com"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq curl
#add CDH repo
RUN curl http://archive.cloudera.com/cdh5/ubuntu/precise/amd64/cdh/archive.key | apt-key add -
RUN curl http://archive.cloudera.com/cdh5/ubuntu/precise/amd64/cdh/cloudera.list > /etc/apt/sources.list.d/cloudera.list
# add CM repo
RUN curl http://archive.cloudera.com/cm5/ubuntu/precise/amd64/cm/archive.key | apt-key add -
@morrislaptop
morrislaptop / stateMock.js
Last active November 23, 2015 08:51 — forked from wilsonwc/stateMock.js
angular.module('stateMock',[]);
angular.module('stateMock').service("$state", function($q){
this.expectedTransitions = [];
this.current = {};
this.transitionTo = function(stateName){
if(this.expectedTransitions.length > 0){
var expectedState = this.expectedTransitions.shift();
if(expectedState !== stateName){
throw Error("Expected transition to state: " + expectedState + " but transitioned to " + stateName );
}