-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathapplicationConfig.js
More file actions
134 lines (123 loc) · 3.65 KB
/
applicationConfig.js
File metadata and controls
134 lines (123 loc) · 3.65 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
* @fileOverview Configuration for a simple Lambda Complex example application.
*
* See examples/exampleApplicationConfig.js for comments explaining the various
* options and parameters.
*/
var path = require('path');
module.exports = {
name: 'simple',
version: '0.1.0',
// Use a unix timestamp for the deploy ID for the sake of simplicity.
deployId: Math.round((new Date()).getTime() / 1000),
deployment: {
// Set the desired region.
region: 'us-east-1',
s3Bucket: 'lambda-complex',
s3KeyPrefix: 'applications/',
// No additional tags.
tags: {},
// No additional duties for the switchover between versions of the
// deployed application.
switchoverFunction: function (stackDescription, config, callback) {
callback();
},
skipPriorCloudFormationStackDeletion: false,
skipPriorCloudWatchLogGroupsDeletion: false,
skipCloudFormationStackDeletionOnFailure: false
},
coordinator: {
coordinatorConcurrency: 2,
maxApiConcurrency: 10,
maxInvocationCount: 20,
minInterval: 10
},
roles: [
{
name: 'default',
// No extra statements beyond those added by default to access queues.
statements: []
}
],
components: [
{
name: 'invokedProcessor',
type: 'eventFromInvocation',
// Since this defines no routing, this is a dead end: events are delivered
// here and no further processing results.
// routing: undefined,
lambda: {
npmPackage: path.join(__dirname, 'processor'),
handler: 'index.handler',
memorySize: 128,
timeout: 60,
role: 'default'
}
},
{
name: 'messageProcessor',
type: 'eventFromMessage',
queueWaitTime: 5,
maxConcurrency: 10,
// Since this defines no routing, this is a dead end: events are delivered
// here and no further processing results.
// routing: undefined,
lambda: {
npmPackage: path.join(__dirname, 'processor'),
handler: 'index.handler',
memorySize: 128,
timeout: 60,
role: 'default'
}
},
{
name: 'messageTransformer',
type: 'eventFromMessage',
maxConcurrency: 10,
queueWaitTime: 5,
/**
* A routing function to send data resulting from this component's Lambda
* function invocation to other components based on its contents.
*
* Remember that (a) the routing function cannot include any reference to
* resources that don't exist in this component Lambda function, and
* (b) this config will be included and loaded in other places that don't
* have the same set of NPM modules available as this Lambda function.
*
* That doesn't matter in this case, but it would if we used require() to
* load modules.
*
* @param {Error} error An Error instance.
* @param {Mixed} data Results of the Lambda function invocation.
*/
routing: function (error, data) {
// Don't send on any data to other components if there was an error in
// processing.
if (error) {
return [];
}
var json = JSON.stringify(data);
var destination;
if (json.length % 2 === 1) {
destination = 'messageProcessor';
}
else {
destination = 'invokedProcessor';
}
return [
{
name: destination,
data: data
}
];
},
lambda: {
npmPackage: path.join(__dirname, 'messageTransformer'),
handler: 'index.handler',
memorySize: 128,
timeout: 60,
role: 'default'
}
}
]
};