Skip to content

Instantly share code, notes, and snippets.

View DaneTheory's full-sized avatar
🏠
Working from home

Branden Dane DaneTheory

🏠
Working from home
View GitHub Profile
@DaneTheory
DaneTheory / S3-Bucket-Auth-Lamda-Func
Last active December 20, 2017 06:14
S3 Bucket Auth Lamda Func Cloudfront config function
let plainTextEmailAddress = null
let cloudFrontPrivateKey = null
const KMS = require('aws-sdk/clients/kms')
const kms = new KMS({apiVersion: '2014-11-01'}) // <==== TODO: CHECK TO SEE IF apiVersion is correct!!!!!!!!!!!!
const crypto = require('crypto')
const headers = {
"Content-Type": "application/json",
"Access-Control-Allow-Headers": "Content-Type",
"Access-Control-Allow-Methods": "OPTIONS,POST",
@raytung
raytung / spike.js
Created October 13, 2016 09:41
AWS KMS NodeJS
/*
* AWS Sdk KMS spike: (assuming node v6.6+)
* 1 - Create master key at KMS
* 2 - Copy alias or ARN
* 3 - run this i.e.
* $ node spike.js KEY_ALIAS YOUR_PLAINTEXT_TO_ENCRYPT
*/
const AWS = require('aws-sdk');
// aws-sdk is not reading my region info so i'll have to set it here
var AWS = require('aws-sdk');
AWS.config.update({
logger: process.stdout,
region: 'ap-northeast-1'
});
var r53 = new AWS.Route53();
var params = {
@simonwhatley
simonwhatley / index.js
Last active December 2, 2018 21:46
Uploading files to AWS S3 using NodeJS
const AWS = require('aws-sdk');
const fs = require('fs');
const path = require('path');
//configuring the AWS environment
AWS.config.update({
accessKeyId: "AWS_ACCESS_KEY",
secretAccessKey: "AWS_SECRET_ACCESS_KEY"
});
@loopj
loopj / fiddle.css
Last active December 2, 2018 21:46
AWS Instance Chart
html, body {
height: 100%;
padding: 0;
margin: 0;
}
#chart {
height: 100%;
}
const aws = require('aws-sdk')
module.exports = {
setupAWS: () => {
aws.config.update(
process.env.NODE_ENV === 'test'
? {
endpoint: `http://localhost:${process.env.DYNAMO_TESTING_PORT}`,
region: 'mock',
credentials: {
@k-oguma
k-oguma / Cloud9_settings
Last active December 2, 2018 21:48
Cloud9 settings. init script, user setting, project setting
# AWS Cloud9 settings
## Prepare
### AWS SSM
Push the your environment variables.
- FYI
- Like a [12 factor app](https://12factor.net/config)
@malkitsingh
malkitsingh / notes.js
Created January 19, 2018 06:19
some of node code snippets
// to upload file to s3 bucket.
var AWS = require('aws-sdk');
AWS.config = new AWS.Config();
AWS.config.accessKeyId = "XXX";
AWS.config.secretAccessKey = "XXXXX";
AWS.config.region = "ap-south-1";
var s3 = new AWS.S3();
@ogawa0071
ogawa0071 / index.js
Created June 20, 2018 04:40
aws-media-services
const AWS = require("aws-sdk");
const medialive = new AWS.MediaLive({
region: "ap-northeast-1"
});
const mediapackage = new AWS.MediaPackage({
region: "ap-northeast-1"
});
const mediastore = new AWS.MediaStore({
region: "ap-northeast-1"
});
@kgajowy
kgajowy / awsbucket.js
Last active December 2, 2018 21:50
AWS S3 Upload
'use strict';
const AWS = require('aws-sdk'),
nConf = require('nconf');
let S3 = null;
function deploy(fileName, fileContent) {
return new Promise((resolve, reject) => {
const expireDate = new Date();