@rlyle1179/serverless-aws-batch 1.1.15 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/generateCoreTemplate.js +40 -0
- package/lib/schedule.js +3 -3
- package/package.json +3 -4
|
@@ -61,6 +61,46 @@ function generateCoreTemplate() {
|
|
|
61
61
|
newECRObject
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
+
// Look for the serverless-log-forwarding custom parameters, if found, then forward the logs
|
|
65
|
+
// from our batch jobs to the same ARN...
|
|
66
|
+
const logDestinationArn = _.get(this.serverless.service,"custom.logForwarding.destinationARN" );
|
|
67
|
+
if ( logDestinationArn ) {
|
|
68
|
+
const batchLogGroupTemplate = {
|
|
69
|
+
"BatchLogGroupLambdaPermission": {
|
|
70
|
+
"Type": "AWS::Lambda::Permission",
|
|
71
|
+
"Properties": {
|
|
72
|
+
"FunctionName": logDestinationArn,
|
|
73
|
+
"Action": "lambda:InvokeFunction",
|
|
74
|
+
"Principal": "logs.us-east-1.amazonaws.com"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"BatchLogGroup": {
|
|
78
|
+
"Type": "AWS::Logs::LogGroup",
|
|
79
|
+
"Properties": {
|
|
80
|
+
"LogGroupName": "/aws/batch/job",
|
|
81
|
+
"RetentionInDays": 7
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"BatchLogGroupSubscriptionFilter": {
|
|
85
|
+
"Type": "AWS::Logs::SubscriptionFilter",
|
|
86
|
+
"Properties": {
|
|
87
|
+
"DestinationArn": logDestinationArn,
|
|
88
|
+
"FilterPattern": "",
|
|
89
|
+
"LogGroupName": "/aws/batch/job"
|
|
90
|
+
},
|
|
91
|
+
"DependsOn": [
|
|
92
|
+
"BatchLogGroupLambdaPermission",
|
|
93
|
+
"BatchLogGroup"
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
_.merge(
|
|
99
|
+
this.serverless.service.provider.compiledCloudFormationTemplate.Resources,
|
|
100
|
+
batchLogGroupTemplate
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
64
104
|
// Then write it back out to the file
|
|
65
105
|
const coreTemplateFileName = this.provider.naming.getCoreTemplateFileName();
|
|
66
106
|
|
package/lib/schedule.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
'use strict';
|
|
9
9
|
const process = require("process");
|
|
10
|
-
const
|
|
11
|
-
const batch = new
|
|
10
|
+
const { BatchClient, SubmitJobCommand } = require('@aws-sdk/client-batch')
|
|
11
|
+
const batch = new BatchClient();
|
|
12
12
|
|
|
13
13
|
function zeroPad(n) {
|
|
14
14
|
return n <= 9 ? "0" + n : n;
|
|
@@ -56,7 +56,7 @@ module.exports.schedule = (event, context, callback) => {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
batch.
|
|
59
|
+
batch.send( new SubmitJobCommand(params), function(err, data) {
|
|
60
60
|
let response;
|
|
61
61
|
|
|
62
62
|
const jsonHeaders = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rlyle1179/serverless-aws-batch",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.17",
|
|
4
4
|
"description": "Serverless Framework Plugin for interacting with AWS Batch",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/rlyle/serverless-aws-batch#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
+
"@aws-sdk/client-batch": "^3.609.0",
|
|
26
27
|
"bluebird": "^3.7.2",
|
|
27
28
|
"cross-spawn": "^6.0.5",
|
|
28
29
|
"fs-extra": "^7.0.1",
|
|
@@ -30,7 +31,5 @@
|
|
|
30
31
|
"lodash": "^4.17.13",
|
|
31
32
|
"serverless": "^1.70.0"
|
|
32
33
|
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"aws-sdk": "^2.672.0"
|
|
35
|
-
}
|
|
34
|
+
"devDependencies": {}
|
|
36
35
|
}
|