@rlyle1179/serverless-aws-batch 1.1.16 → 1.1.18

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/batchtask.js CHANGED
@@ -206,6 +206,17 @@ function updateContainerProperties(newFunction, functionObject, functionName) {
206
206
  });
207
207
  }
208
208
  );
209
+
210
+ const logGroupName = _.get(this.serverless.service,"custom.awsBatch.logGroupName");
211
+ if ( logGroupName ) {
212
+ newFunction.Properties.ContainerProperties.LogConfiguration = {
213
+ LogDriver: 'awslogs',
214
+ Options: {
215
+ "awslog-group": logGroupName,
216
+ "awslog-stream-prefix": "batch"
217
+ }
218
+ }
219
+ }
209
220
  }
210
221
 
211
222
  /**
@@ -61,6 +61,47 @@ 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 logGroupName = _.get(this.serverless.service,"custom.awsBatch.logGroupName");
67
+ const logDestinationArn = _.get(this.serverless.service,"custom.logForwarding.destinationARN" );
68
+ if ( logDestinationArn && logGroupName ) {
69
+ const batchLogGroupTemplate = {
70
+ "BatchLogGroupLambdaPermission": {
71
+ "Type": "AWS::Lambda::Permission",
72
+ "Properties": {
73
+ "FunctionName": logDestinationArn,
74
+ "Action": "lambda:InvokeFunction",
75
+ "Principal": "logs.us-east-1.amazonaws.com"
76
+ }
77
+ },
78
+ "BatchLogGroup": {
79
+ "Type": "AWS::Logs::LogGroup",
80
+ "Properties": {
81
+ "LogGroupName": logGroupName,
82
+ "RetentionInDays": 7
83
+ }
84
+ },
85
+ "BatchLogGroupSubscriptionFilter": {
86
+ "Type": "AWS::Logs::SubscriptionFilter",
87
+ "Properties": {
88
+ "DestinationArn": logDestinationArn,
89
+ "FilterPattern": "",
90
+ "LogGroupName": logGroupName
91
+ },
92
+ "DependsOn": [
93
+ "BatchLogGroupLambdaPermission",
94
+ "BatchLogGroup"
95
+ ]
96
+ }
97
+ }
98
+
99
+ _.merge(
100
+ this.serverless.service.provider.compiledCloudFormationTemplate.Resources,
101
+ batchLogGroupTemplate
102
+ );
103
+ }
104
+
64
105
  // Then write it back out to the file
65
106
  const coreTemplateFileName = this.provider.naming.getCoreTemplateFileName();
66
107
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rlyle1179/serverless-aws-batch",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "description": "Serverless Framework Plugin for interacting with AWS Batch",
5
5
  "main": "index.js",
6
6
  "scripts": {