-
Notifications
You must be signed in to change notification settings - Fork 20
/
aws_wrapper.js
84 lines (73 loc) · 2.37 KB
/
aws_wrapper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* Created by ejf3 on 11/20/13.
*/
var AWS = require('aws-sdk');
/**
* Don't hard-code your credentials!
* Export the following environment variables instead:
*
* export AWS_ACCESS_KEY_ID='AKID'
* export AWS_SECRET_ACCESS_KEY='SECRET'
* export AWS_RDS_HOST='hostname'
* export AWS_RDS_MYSQL_USERNAME='username'
* export AWS_RDS_MYSQL_PASSWORD='pass'
*/
AWS.config.region = "us-east-1";
AWS.config.apiVersions = {
s3: '2006-03-01',
rds: '2013-09-09',
dynamodb: '2012-08-10',
sns: '2010-03-31',
ses: '2010-12-01'
};
var dynamoUsers = require('./dynamo-demo/users.js')
, dynamoMedia = require('./dynamo-demo/media.js')
, dynamoEmail = require('./dynamo-demo/email.js')
, rdsUsers = require('./rds-demo/users.js')
, rdsMedia = require('./rds-demo/media.js')
, S3Utils = require('./s3-demo/s3_utils.js')
, userActivity = require('./ses-demo/user_activity.js')
, bounce = require('./ses-demo/bounces.js')
;
if (process === undefined) {
console.error('no process found');
return;
}
var mysqlHost = process.env['AWS_RDS_HOST'];
var mysqlUserName = process.env['AWS_RDS_MYSQL_USERNAME'];
var mysqlPassword = process.env['AWS_RDS_MYSQL_PASSWORD'];
if (!mysqlHost || !mysqlPassword || !mysqlUserName) {
console.error('no process found');
return;
}
var rds_conf = {
host: mysqlHost,
database: "aws_node_demo",
user: mysqlUserName,
password: mysqlPassword
};
function AwsWrapper () {
// AWS services
this.s3 = new AWS.S3();
this.ses = new AWS.SES();
this.sns = new AWS.SNS();
this.dynamodb = new AWS.DynamoDB();
this.rds = new AWS.RDS();
// S3
console.log('init s3 wrapper');
this.S3Utils = new S3Utils(this.s3);
// Dynamo
console.log('init dynamo wrappers');
this.DynamoMedia = new dynamoMedia(this.dynamodb, this.S3Utils);
this.DynamoUsers = new dynamoUsers(this.dynamodb, this.DynamoMedia);
this.DynamoEmail = new dynamoEmail(this.dynamodb);
// RDS
console.log('init rds wrappers');
this.RdsMedia = new rdsMedia(this.rds, rds_conf, this.S3Utils);
this.RdsUsers = new rdsUsers(this.rds, rds_conf, this.RdsMedia);
// SES
console.log('init ses wrappers');
this.SesUserActivity = new userActivity(this.ses, this.DynamoMedia, this.DynamoEmail);
this.SesBounce = new bounce(this.sns, this.ses, this.DynamoEmail);
};
module.exports = AwsWrapper;