This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var aws = require('aws-sdk') | |
var express = require('express') | |
var multer = require('multer') | |
var multerS3 = require('multer-s3') | |
var app = express() | |
var s3 = new aws.S3({ | |
accessKeyId: '', | |
secretAccessKey: '', | |
region: 'ap-southeast-1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instructions from the app developer | |
# - you should use the 'node' official image, with the alpine 6.x branch | |
FROM node:latest | |
# - this app listens on port 3000, but the container should launch on port 80 | |
# so it will respond to http://localhost:80 on your computer | |
EXPOSE 1337 | |
# - then it should use alpine package manager to install tini: 'apk add --update tini' | |
# RUN apk add --update tini | |
# - then it should create directory /usr/src/app for app files with 'mkdir -p /usr/src/app' | |
RUN mkdir -p /usr/src/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# AWS CLI | |
apt-get install zip -y; | |
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"; | |
unzip awscli-bundle.zip; | |
./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws; | |
aws configure; | |
#AWS Access Key ID [None]: Obtained when creating user in AWS IAM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# App ship-it stack with ECS, CodeBuild & CodePipeline. | |
# | |
# aws cloudformation deploy \ | |
# --stack-name myapp-prod \ | |
# --template-file ./aws-ship-it-stack.yaml \ | |
# --parameter-overrides \ | |
# KeyName=<KEY_NAME> \ | |
# GitHubAuthToken=<ACCESS_TOKEN> \ | |
# RepoOwner=<OWNER_NAME> \ | |
# RepoName=<REPO_NAME> \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const MongoClient = require('mongodb').MongoClient; | |
const MONGODB_URI = process.env.MONGODB_URI; | |
let cachedDb = null; | |
function connectToDatabase (uri) { | |
if (cachedDb) { | |
return Promise.resolve(cachedDb); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AWS = require("aws-sdk"); | |
var lambda = new AWS.Lambda({ | |
region: 'ap-southeast-1' | |
}); | |
function mongodbMonitorResult() { | |
return new Promise(function(resolve, reject) { | |
lambda.invoke({ | |
FunctionName: process.env.MongoMonitorLambdaARN, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Make sure your Subnet has internet access | |
variable "subnet" {} | |
variable "vpc" {} | |
provider "aws" { | |
region = "us-east-1" | |
} | |
data "aws_vpc" "sample" { | |
id = "${var.vpc}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
by Martin Güther @magegu | |
just call it: | |
uploadFile(absoluteFilePath, callback); | |
*/ | |
var path = require('path'); | |
var async = require('async'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// credit goes to this stack overflow post - http://stackoverflow.com/questions/20646836/is-there-any-way-to-import-a-json-filecontains-100-documents-in-elasticsearch | |
var elasticsearch = require('elasticsearch'), | |
fs = require('fs'), | |
pubs = JSON.parse(fs.readFileSync(__dirname + '/pubs.json')), // name of my first file to parse | |
forms = JSON.parse(fs.readFileSync(__dirname + '/forms.json')); // and the second set | |
var client = new elasticsearch.Client({ // default is fine for me, change as you see fit | |
host: 'localhost:9200', | |
log: 'trace' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
Description: AWSAppSync DynamoDB Example | |
Resources: | |
GraphQLApi: | |
Type: "AWS::AppSync::GraphQLApi" | |
Properties: | |
Name: AWSAppSync DynamoDB Example | |
AuthenticationType: AWS_IAM | |
PostDynamoDBTableDataSource: |