Skip to content

Instantly share code, notes, and snippets.

Alex Banks alexanderbanks

View GitHub Profile
@alexanderbanks
alexanderbanks / updated-app.js
Created Mar 19, 2018
An updated Express app to connect to Docker locally
View updated-app.js
const express = require('express');
const AWS = require('aws-sdk');
AWS.config.update({
region: 'us-west-2',
endpoint: 'http://docker.for.mac.host.internal:8888'
});
const dc = new AWS.DynamoDB.DocumentClient();
const app = express();
View schema.json
{
"TableName": "apptable",
"KeySchema": [
{ "AttributeName": "timestamp", "KeyType": "RANGE"}
],
"AttributeDefinitions": [
{"AttributeName": "timestamp", "AttributeType": "N"},
],
"ProvisionedThroughput": {
"ReadCapacityUnits": 5,
@alexanderbanks
alexanderbanks / sam-template-with-dynamoDB.yaml
Last active Dec 24, 2018
A sam template with a function and a dynamoDB table
View sam-template-with-dynamoDB.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
AppFunction:
Type: AWS::Serverless::Function
Properties:
Handler: app/index.handler
Runtime: nodejs6.10
Timeout: 60
View app.js
const express = require('express');
const app = express();
app.get('/test', (req, res) => {
res.send('Function Created!');
});
module.exports = app;
@alexanderbanks
alexanderbanks / index.js
Created Mar 19, 2018
An index file for a SAM template
View index.js
const awsServerlessExpress = require('aws-serverless-express');
const app = require('./app');
const server = awsServerlessExpress.createServer(app);
exports.handler = (event, context) => awsServerlessExpress.proxy(server, event, context);
View first-sam-template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
AppFunction:
Type: AWS::Serverless::Function
Properties:
Handler: app/index.handler
Runtime: nodejs6.10
Timeout: 60
You can’t perform that action at this time.