forked from awslabs/aws-lambda-redshift-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doSetup.js
103 lines (96 loc) · 2.45 KB
/
doSetup.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Amazon Software License (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/asl/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
var aws = require('aws-sdk');
var common = require('./common');
var pjson = require('./package.json');
var uuid = require('node-uuid');
// configure dynamo db, kms, s3 and lambda for the correct region
var setRegion = "eu-west-1";
var dynamoDB = new aws.DynamoDB({
apiVersion : '2012-08-10',
region : setRegion
});
var s3 = new aws.S3({
apiVersion : '2006-03-01'
});
var lambda = new aws.Lambda({
apiVersion : '2015-03-31',
region : setRegion
});
var dynamoConfig = {
TableName : configTable,
Item : {
currentBatch : {
S : uuid.v4()
},
version : {
S : pjson.version
},
loadClusters : {
L : [ {
M : {
}
} ]
}
}
};
dynamoConfig.Item.s3Prefix = {
S : "meyersi-ire/AMS"
};
dynamoConfig.Item.loadClusters.L[0].M.clusterEndpoint = {
S : "localhost"
};
dynamoConfig.Item.loadClusters.L[0].M.clusterPort = {
N : '' + 5439
};
dynamoConfig.Item.loadClusters.L[0].M.useSSL = {
BOOL : false
};
dynamoConfig.Item.loadClusters.L[0].M.clusterDB = {
S : "master"
};
dynamoConfig.Item.loadClusters.L[0].M.connectUser = {
S : "master"
};
dynamoConfig.Item.loadClusters.L[0].M.connectPassword = {
S : "unencryptedUnusuablePassword"
};
dynamoConfig.Item.loadClusters.L[0].M.targetTable = {
S : "ian_test"
};
dynamoConfig.Item.loadClusters.L[0].M.truncateTarget = {
BOOL : false
};
dynamoConfig.Item.dataFormat = {
S : "CSV"
};
dynamoConfig.Item.csvDelimiter = {
S : ","
};
dynamoConfig.Item.manifestBucket = {
S : "meyersi-ire"
};
dynamoConfig.Item.manifestKey = {
S : "redshift/manifest"
};
dynamoConfig.Item.failedManifestKey = {
S : "redshift/manifest/failed"
};
dynamoConfig.Item.batchSize = {
N : '' + 1
};
dynamoConfig.Item.batchTimeoutSecs = {
N : '' + 100
};
common.setup(dynamoConfig, dynamoDB, s3, lambda, function(err) {
if (err) {
console.log("Test Error");
console.log(err);
} else {
console.log("Test OK");
}
});