Skip to content

Instantly share code, notes, and snippets.

@ppshein
ppshein / list.txt
Created February 23, 2020 14:29 — forked from shortjared/list.txt
List of AWS Service Principals
acm.amazonaws.com
alexa-appkit.amazon.com
apigateway.amazonaws.com
application-autoscaling.amazonaws.com
appstream.application-autoscaling.amazonaws.com
appsync.amazonaws.com
athena.amazonaws.com
autoscaling.amazonaws.com
batch.amazonaws.com
channels.lex.amazonaws.com
@ppshein
ppshein / Simple-S3Bucket-SNS
Created February 22, 2020 08:30 — forked from austoonz/Simple-S3Bucket-SNS
A CloudFormation template sample for creating an S3 Bucket with an SNS Trigger.
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Simple S3 Bucket with SNS Trigger
Parameters:
BucketName:
Type: String
Description: The name of the S3 Bucket to create
@ppshein
ppshein / index.js
Created January 31, 2020 10:25
Check index whether exist or not then if not yet exist, create Index and Save document.
const elasticsearch = require('elasticsearch');
const esClient = new elasticsearch.Client({
host: process.env.ES_ENDPOINT,
apiVersion: "7.1",
});
exports.handler = async (event, context, callback) => {
const indexName = 'notifications';
const id = event.input.id;
const documents = event.input;
@ppshein
ppshein / AppSyncAPI.yaml
Created January 17, 2020 09:18 — forked from adrianhall/AppSyncAPI.yaml
A CloudFormation template for DynamoDB + Cognito User Pool + AppSync API for the Notes tutorial
---
Description: AWS AppSync Notes API
Parameters:
APIName:
Type: String
Description: Name of the API - used to generate unique names for resources
MinLength: 3
MaxLength: 20
AllowedPattern: '^[a-zA-Z][a-zA-Z0-9_]*$'
@ppshein
ppshein / AppSync-Example.yaml
Created January 17, 2020 09:12 — forked from adrianhall/AppSync-Example.yaml
An example CloudFormation template for AWS AppSync
---
Description: AWSAppSync DynamoDB Example
Resources:
GraphQLApi:
Type: "AWS::AppSync::GraphQLApi"
Properties:
Name: AWSAppSync DynamoDB Example
AuthenticationType: AWS_IAM
PostDynamoDBTableDataSource:
@ppshein
ppshein / elasticsearchbulkimport.js
Created November 13, 2019 04:05 — forked from nicholasblexrud/elasticsearchbulkimport.js
Bulk upload files using Node.js to Elasticsearch
// 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'
});
@ppshein
ppshein / multipart.js
Created October 27, 2019 03:16 — forked from magegu/multipart.js
mutipart upload for aws s3 with nodejs based on the async lib including retries for part uploads
/*
by Martin Güther @magegu
just call it:
uploadFile(absoluteFilePath, callback);
*/
var path = require('path');
var async = require('async');
@ppshein
ppshein / main.tf
Created October 21, 2019 01:23 — forked from carlochess/main.tf
aws batch terraform example
## Make sure your Subnet has internet access
variable "subnet" {}
variable "vpc" {}
provider "aws" {
region = "us-east-1"
}
data "aws_vpc" "sample" {
id = "${var.vpc}"
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,
"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);