Skip to content

Instantly share code, notes, and snippets.

View pbzona's full-sized avatar
🤠
having fun on the computer

Phil Z pbzona

🤠
having fun on the computer
View GitHub Profile
@pbzona
pbzona / ContactFormLambda.js
Last active October 2, 2017 22:01
Callbacks for serverless contact form
callback(null, “this was successful”);
// ...
callback(“this was a failure”);
@pbzona
pbzona / ContactFormLambda.js
Last active October 2, 2017 22:03
Sample request body for serverless contact form
{
"email": "your-test-destination@email",
"subject": "test from apigw",
"message": "this is a test message"
}
@pbzona
pbzona / index.html
Last active November 7, 2017 21:19
<!DOCTYPE html>
<html>
<head>
<title>My Contact Form Microservice</title>
<style>
/* It's not pretty, but it'll do :) */
input,
textarea {
display: block;
margin: 20px;
@pbzona
pbzona / index.js
Last active November 4, 2017 20:37
Implement your first microservice - event listener
document.getElementById('serverless-contact-form').addEventListener('submit', sendDataToLambda);
@pbzona
pbzona / index.js
Created November 4, 2017 20:42
Implement your first microservice - getting our user values
var formEmail = document.querySelector('.form-email').value;
var formSubject = document.querySelector('.form-subject').value;
var formMessage = document.querySelector('.form-message').value;
@pbzona
pbzona / index.js
Created November 4, 2017 20:46
Implement your first microservice - define your endpoint
var endpoint = 'https://your-api-gateway-endpoint.com/ContactFormLambda';
@pbzona
pbzona / index.js
Created November 4, 2017 20:59
Implement your first microservice - create a body object
var body = {
email: formEmail,
subject: formSubject,
message: formMessage
}
@pbzona
pbzona / index.js
Created November 4, 2017 21:03
Implement your first microservice - create a request object
var lambdaRequest = new Request(endpoint, {
method: 'POST',
mode: 'no-cors',
body: JSON.stringify(body)
});
@pbzona
pbzona / index.js
Created November 4, 2017 21:15
Implement your first microservice - making your POST request
fetch(lambdaRequest)
.then(response => console.log(response))
.catch(err => console.log(err));
@pbzona
pbzona / vpn-cloudformation-template.yaml
Created November 14, 2017 01:17
Roll your own VPN with AWS CloudFormation - Part One
# Credit to John Creecy
# Original can be found at https://gist.github.com/zugdud/0bf8b2bab65ede19dc42a58d2db721a4
AWSTemplateFormatVersion: '2010-09-09'
Description: OpenVPN Stack
Parameters:
OpenVPNPort:
Type: Number
Default: 1194