-
Notifications
You must be signed in to change notification settings - Fork 1
/
pause.js
38 lines (26 loc) · 801 Bytes
/
pause.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
'use strict';
const AWS = require('aws-sdk');
AWS.config.update({region: 'ap-southeast-2'});
const lambda = new AWS.Lambda();
module.exports.handler = async (event, context) => {
const fn = event.pathParameters['fn'];
const concurrency = event.queryStringParameters && event.queryStringParameters['concurrency'] || 0;
const params = {
FunctionName: fn,
ReservedConcurrentExecutions: concurrency
};
console.log(params);
try {
const data = await lambda.putFunctionConcurrency(params).promise();
console.log(data);
return {
statusCode: 200,
body: JSON.stringify(data),
};
} catch(err) {
return {
statusCode: 500,
body: JSON.stringify(err),
};
}
};