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.
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
@cerdman
cerdman / redis_cheatsheet.bash
Created November 8, 2017 02:19 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@cerdman
cerdman / main.py
Created October 21, 2016 05:14
BOTO: threaded SQS connections
#!/usr/bin/env python
from boto import sqs
from boto.sqs.message import Message
import threading, logging, time
CONSUMERS = 30
PRODUCERS = 5
MAX_MESAGES = 10
@cerdman
cerdman / complete.sh
Created March 3, 2016 20:41 — forked from pcreux/complete.sh
Github Commit Status API with Bamboo from Atlassian. Add those to your plan as Script.
# specs and cukes results are stored in JUnit format under test-reports
if (grep 'failures="[^0]"' test-reports/* || grep 'errors="[^0]"' test-reports/*); then
curl -H "Authorization: token MY_TOKEN" --request POST --data '{"state": "failure", "description": "Failed!", "target_url": "${bamboo.buildResultsUrl}"}' https://api.github.com/repos/USER/REPO/statuses/${bamboo.repository.revision.number} > /dev/null
else
curl -H "Authorization: token MY_TOKEN" --request POST --data '{"state": "success", "description": "Success!", "target_url": "${bamboo.buildResultsUrl}"}' https://api.github.com/repos/USER/REPO/statuses/${bamboo.repository.revision.number} > /dev/null
fi
@cerdman
cerdman / ElasticSearch.sh
Created October 7, 2015 21:26 — forked from ricardo-rossi/ElasticSearch.sh
Installing ElasticSearch on Ubuntu 14.04
#!/bin/bash
### USAGE
###
### ./ElasticSearch.sh 1.7 will install Elasticsearch 1.7
### ./ElasticSearch.sh will fail because no version was specified (exit code 1)
###
### CLI options Contributed by @janpieper
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch
@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):
@cerdman
cerdman / gist:64c532542f9208eacb36
Last active September 21, 2015 18:54 — forked from brantfaircloth/gist:764363
dynamic tests generation that works in unittest and nose
# modified from http://bit.ly/dEyw03
import unittest
class TestMyGoods(unittest.TestCase):
pass
def create_dynamic_method(pair):
"""just don't include `test` in the function name here, nose will try to
run it"""
<!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>
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="https://cdn.rawgit.com/lodash/lodash/3.5.0/lodash.min.js"></script>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>