Skip to content

Instantly share code, notes, and snippets.

View loopiezlol's full-sized avatar

Cătălin Buruiană loopiezlol

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.
const currPath = 'path';
const aspects = ['new', 'workout', 'blah'];
fs
.readDirSync(currPath)
.filter(folder => folder !== 'archived')
.forEach(topicName =>
fs
.readDirSync(path.join(currFolder, topicName))
.filter(folder => folder !== 'README.md')
@loopiezlol
loopiezlol / git-lambda.js
Created April 10, 2018 14:12
flow showing off how to clone, update and push to a git repo from an AWS lambda function
const fs = require('fs')
const path = require('path')
const process = require('process')
const { spawnSync } = require('child_process')
const { GITHUB_TOKEN, GITHUB_USERNAME, GITHUB_EMAIL } = process.env
// leaving this without https:// in order to reuse it when adding the remote
const gitRepositoryURL = 'github.com/owner/repo-name.git'
const repositoryName = 'repo-name'
export default function (string) {
return (
string
.toLowerCase()
.replace(/\s+/g, '-')
// eslint-disable-next-line
.replace(/[^\w\-]+/g, '')
// eslint-disable-next-line
.replace(/\-\-+/g, '-')
.replace(/^-+/, '')
const co = require('co');
const fs = require('fs');
const User = require('../../app/models/user');
const Topic = require('../../app/models/topic');
const Insight = require('../../app/models/insight');
const Level = require('../../app/models/level');
const Subtopic = require('../../app/models/subtopic');
// function to dynamically instantinate nested objects by assignment
// const util = require('util');
const co = require('co');
const fs = require('fs');
const C = require('common/constants');
const User = require('../../app/models/user');
const InsightReview = require('../../app/models/insightReview');
const Topic = require('../../app/models/topic');
const Insight = require('../../app/models/insight');
const co = require('co');
const moment = require('moment');
const User = require('../../app/models/user');
const Workout = require('../../app/models/workout');
/*
Script used to get an accurate estimate of returning users on a specific date
( + the following day ).
E.g. On 13th of July we sent an email. The question is how many users that dind't
const co = require('co');
require('../../app/models/topic');
require('../../app/models/level');
const User = require('../../app/models/user');
const Workout = require('../../app/models/workout');
module.exports = function() {
co(function*() {
const User = require('../../app/models/user');
module.exports = function() {
const query = {
topics: { $exists: true},
'onboardingSteps.0': 'revision',
}
/* eslint-disable */
const o = {},
const co = require('co');
const fs = require('fs');
require('../../app/models/topic');
require('../../app/models/level');
const User = require('../../app/models/user');
function extractLevelMajority(topicsArray) {
let beginner = 0;