@kumologica/sdk 3.2.0-beta13 → 3.2.0-beta15

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.
@@ -158,14 +158,15 @@ Examples:
158
158
  Cloudwatch Event:\n-----------------
159
159
  * schedule - cron expression (minutes hours days-of-month month days-of-week year) or fixed rate expression, required.\n See more: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-create-rule-schedule.html
160
160
  * name - the name of event, optional, default value: Event+timestamp if not provided
161
+ * state - state of event rule: ENABLED or DISABLED, default ENABLED
161
162
  * reference - the reference property set for event listener node that should handle event. Optional
162
163
 
163
164
  Examples:
164
165
  1. Creates event trigger using cron expression that runs at 10am UTC every day:\n
165
166
  {"event": {"expression": "cron(0 10 * * ? *)"}}
166
167
 
167
- 2. Creates event trigger using rate expression that runs every minute:\n
168
- {"event": {"expression": "rate(1 minute)"}}\n
168
+ 2. Creates event trigger using rate expression that runs every minute and is initially disabled:\n
169
+ {"event": {"expression": "rate(1 minute), "state": "DISABLED"}}\n
169
170
 
170
171
  3. Creates event trigger using rate expression that runs every minute for event listener with reference "cleanup":\n
171
172
  {"event": {"expression": "rate(1 minute)", "reference": "cleanup"}}\n
@@ -29,6 +29,12 @@ const triggersSchema = {
29
29
  "title": "Event name",
30
30
  "type": "string"
31
31
  },
32
+ "state": {
33
+ "$id": "#root/items/event/state",
34
+ "title": "State",
35
+ "type": "string",
36
+ "enum": ["DISABLED", "ENABLED"]
37
+ },
32
38
  "reference": {
33
39
  "$id": "#root/items/event/reference",
34
40
  "title": "Event Listener reference",
@@ -168,8 +174,52 @@ const triggersSchema = {
168
174
  }
169
175
  }
170
176
  }
177
+ },
178
+ "websocket": {
179
+ "$id": "#root/items/websocket",
180
+ "title": "Api",
181
+ "type": "object",
182
+ required: [],
183
+ additionalProperties: false,
184
+ required: ["apiId"],
185
+ "properties": {
186
+ "apiId": {
187
+ "$id": "#root/items/websocket/apiId",
188
+ "title": "ApiId",
189
+ "type": "string",
190
+ "pattern": "^.*$"
191
+ },
192
+ "apiName": {
193
+ "$id": "#root/items/websocket/apiName",
194
+ "title": "ApiName",
195
+ "type": "string",
196
+ "pattern": "^.*$"
197
+ },
198
+ "stage": {
199
+ "$id": "#root/items/websocket/stage",
200
+ "title": "Stage",
201
+ "type": "string",
202
+ "pattern": "^.*$"
203
+ },
204
+ "authorizerId": {
205
+ "$id": "#root/items/websocket/authorizerId",
206
+ "title": "Authorizerid",
207
+ "type": "string",
208
+ "pattern": "^.*$"
209
+ },
210
+ "authorizerType": {
211
+ "$id": "#root/items/websocket/authorizerType",
212
+ "title": "AuthorizerType",
213
+ "type": "string",
214
+ "pattern": "^.*$"
215
+ },
216
+ "apiKeyRequired": {
217
+ "$id": "#root/items/websocket/apiKeyRequired",
218
+ "title": "ApiKeyRequired",
219
+ "type": "boolean"
220
+ }
221
+ }
171
222
  }
172
-
173
223
  }
174
224
  }
175
225
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "productName": "Kumologica Designer",
4
4
  "copyright": "Copyright 2020 Kumologica Pty Ltd, All Rights Reserved.",
5
5
  "author": "Kumologica Pty Ltd <contact@kumologica.com>",
6
- "version": "3.2.0-beta13",
6
+ "version": "3.2.0-beta15",
7
7
  "description": "Kumologica Designer, harnessing Serverless for your cloud integration needs",
8
8
  "main": "src/app/main.js",
9
9
  "files": [
@@ -64,9 +64,9 @@
64
64
  "license": "Proprietary",
65
65
  "dependencies": {
66
66
  "@electron/remote": "^2.0.8",
67
- "@kumologica/builder": "3.2.0-beta13",
68
- "@kumologica/devkit": "3.2.0-beta13",
69
- "@kumologica/runtime": "3.2.0-beta13",
67
+ "@kumologica/builder": "3.2.0-beta15",
68
+ "@kumologica/devkit": "3.2.0-beta15",
69
+ "@kumologica/runtime": "3.2.0-beta15",
70
70
  "adm-zip": "0.4.13",
71
71
  "ajv": "8.10.0",
72
72
  "archive-type": "^4.0.0",
@@ -1,7 +1,6 @@
1
1
  const fs = require('fs-extra');
2
2
  const path = require('path');
3
3
  const AWS = require('aws-sdk');
4
- const AWSCFTemplate = require('./cf');
5
4
  const CAAWSCloudWatch = require('./ca-cloudwatch-api');
6
5
  const CAS3 = require('./ca-s3-api');
7
6
  const CASNS = require('./ca-sns-api');
@@ -14,7 +13,7 @@ const { openFileOnEditor } = require('../utils/editor');
14
13
  const { exp } = require('@kumologica/builder');
15
14
  const { build } = require('@kumologica/builder');
16
15
 
17
- /**
16
+ /**
18
17
  * sample events:
19
18
  * https://docs.aws.amazon.com/lambda/latest/dg/lambda-services.html
20
19
  */
@@ -44,7 +43,6 @@ class AWSDeployer {
44
43
  this.sns = new CASNS(this.log.bind(this));
45
44
  this.sqs = new CASQS(this.log.bind(this));
46
45
  this.lambdaApi = new AWS.Lambda();
47
- this.cfTemplate = new AWSCFTemplate();
48
46
  this.cwLogs = new CAAWSCloudWatch(this.logCloud.bind(this));
49
47
  this.cwevents = new AWS.CloudWatchEvents();
50
48
  this.cognito = new AWS.CognitoIdentityServiceProvider();
@@ -180,7 +178,7 @@ class AWSDeployer {
180
178
  settings.flowName
181
179
  );
182
180
 
183
- const zipFileName = await this.buildLambda(settings, projectInfo);
181
+ await this.buildLambda(settings, projectInfo);
184
182
 
185
183
  const nodes = this.loadJsonFile(
186
184
  path.join(projectInfo.projectDir, projectInfo.projectFlowName)
@@ -212,95 +210,87 @@ class AWSDeployer {
212
210
  this.cwLogs.startCWLogs(settings.functionName, AWS.config.region);
213
211
  this.cw = true;
214
212
  }*/
215
- } catch (error) {
216
- this.log(`${this.chalk('redBright', 'Deployment failed.')}`);
217
- this.log(` ${this.chalk('redBright', error)}`);
218
- } finally {
219
- //this.s3.deleteS3Bucket(deploymentBucketName);
220
- }
221
213
 
222
- let response = {};
223
- if (lambdaArn) {
224
- try {
225
- response = await this.runTriggers(params, settings, lambdaArn);
226
- if (response) {
227
- const url = `https://${response.apiId}.execute-api.${AWS.config.region}.amazonaws.com/${response.stage}`;
228
- this.printSignature(url, flowListeners, params);
229
- }
230
- } catch (error) {
231
- this.log(`${this.chalk('redBright', 'Trigger creation failed.')}`);
232
- this.log(` ${this.chalk('redBright', error)}`);
233
- }
234
- }
235
- return response;
214
+ } catch (error) {
215
+ this.log(`${this.chalk('redBright', 'Deployment failed.')}`);
216
+ this.log(` ${this.chalk('redBright', error)}`);
217
+ } finally {
218
+ //this.s3.deleteS3Bucket(deploymentBucketName);
219
+ }
220
+
221
+ if (lambdaArn) {
222
+ // response = await this.runTriggers(params, settings, lambdaArn);
223
+ const url = `https://${response.apiId}.execute-api.${AWS.config.region}.amazonaws.com/${response.stage}`;
224
+ this.printSignature(url, flowListeners, params);
236
225
  }
226
+ }
237
227
 
238
- printSignature(url, s, p) {
239
- this.log(' ')
240
-
241
- if (s.api && s.api.length > 0) {
242
- this.log('API Gateway:');
243
- s.api.forEach(a => this.log(` ${(' ' + a.verb.toUpperCase()).slice(-6)} ${url}${a.url}`), this);
244
- this.log('');
245
- }
228
+ printSignature(url, s, p) {
229
+ this.log(' ')
246
230
 
247
- if (s.dynamodb && s.dynamodb.length > 0) {
248
- this.log('DynamoDB Streams:');
249
- s.dynamodb.forEach(a => this.log(` ${a.startingPosition} ${a.stream}`), this);
250
- this.log('');
251
- }
231
+ if (s.api && s.api.length > 0) {
232
+ this.log('API Gateway:');
233
+ s.api.forEach(a => this.log(` ${(' ' + a.verb.toUpperCase()).slice(-6)} ${url}${a.url}`), this);
234
+ this.log('');
235
+ }
252
236
 
253
- if (s.s3 && s.s3.length > 0) {
254
- this.log('S3:');
255
- s.s3.forEach(a => this.log(` ${a.eventType} ${a.bucket}`), this);
256
- this.log('');
257
- }
258
-
259
- if (s.sns && s.sns.length > 0) {
260
- this.log('SNS Topics:');
261
- s.sns.forEach(a => this.log(` ${a.topic}`), this);
262
- this.log('');
263
- }
264
-
265
- if (s.iot && s.iot.length > 0) {
266
- this.log('IOT:');
267
- s.iot.forEach(a => this.log(` ${a.rule} ${a.query}`), this);
268
- this.log('');
269
- }
237
+ if (s.dynamodb && s.dynamodb.length > 0) {
238
+ this.log('DynamoDB Streams:');
239
+ s.dynamodb.forEach(a => this.log(` ${a.startingPosition} ${a.stream}`), this);
240
+ this.log('');
241
+ }
270
242
 
271
- if (s.alb && s.alb.length > 0) {
272
- this.log('Application Load Balancer:');
273
- s.alb.forEach(a => this.log(` ${a.alb} ${a.listener}`), this);
274
- this.log('');
275
- }
243
+ if (s.s3 && s.s3.length > 0) {
244
+ this.log('S3:');
245
+ s.s3.forEach(a => this.log(` ${a.eventType} ${a.bucket}`), this);
246
+ this.log('');
247
+ }
276
248
 
277
- if (p.events && p.events.length > 0) {
278
- const sqs = p.events.filter(i => i.source == 'sqs');
279
- if (sqs && sqs.length > 0) {
280
- this.log('SQS URL:');
281
- sqs.forEach(a => this.log(` ${a.url}`), this);
282
- this.log('');
283
- }
284
- }
249
+ if (s.sns && s.sns.length > 0) {
250
+ this.log('SNS Topics:');
251
+ s.sns.forEach(a => this.log(` ${a.topic}`), this);
252
+ this.log('');
253
+ }
285
254
 
286
- if (s.alexa && s.alexa.length > 0) {
287
- this.log('Alexa Skills:');
288
- s.alexa.forEach(a => this.log(` ${a.skillId}`), this);
289
- this.log('');
290
- }
255
+ if (s.iot && s.iot.length > 0) {
256
+ this.log('IOT:');
257
+ s.iot.forEach(a => this.log(` ${a.rule} ${a.query}`), this);
258
+ this.log('');
259
+ }
291
260
 
292
- if (s.kinesis && s.kinesis.length > 0) {
293
- this.log('Kinesis:');
294
- s.kinesis.forEach(a => this.log(` ${a.startingPosition} ${a.stream}`), this);
295
- this.log('');
296
- }
261
+ if (s.alb && s.alb.length > 0) {
262
+ this.log('Application Load Balancer:');
263
+ s.alb.forEach(a => this.log(` ${a.alb} ${a.listener}`), this);
264
+ this.log('');
265
+ }
297
266
 
298
- if (s.cwevents && s.cwevents.length > 0) {
299
- this.log('Cloud Watch Events Rules:');
300
- s.cwevents.forEach(a => this.log(` ${a.rule}`), this);
301
- this.log('');
302
- }
267
+ if (p.events && p.events.length > 0) {
268
+ const sqs = p.events.filter(i => i.source == 'sqs');
269
+ if (sqs && sqs.length > 0) {
270
+ this.log('SQS URL:');
271
+ sqs.forEach(a => this.log(` ${a.url}`), this);
272
+ this.log('');
303
273
  }
274
+ }
275
+
276
+ if (s.alexa && s.alexa.length > 0) {
277
+ this.log('Alexa Skills:');
278
+ s.alexa.forEach(a => this.log(` ${a.skillId}`), this);
279
+ this.log('');
280
+ }
281
+
282
+ if (s.kinesis && s.kinesis.length > 0) {
283
+ this.log('Kinesis:');
284
+ s.kinesis.forEach(a => this.log(` ${a.startingPosition} ${a.stream}`), this);
285
+ this.log('');
286
+ }
287
+
288
+ if (s.cwevents && s.cwevents.length > 0) {
289
+ this.log('Cloud Watch Events Rules:');
290
+ s.cwevents.forEach(a => this.log(` ${a.rule}`), this);
291
+ this.log('');
292
+ }
293
+ }
304
294
 
305
295
  processFlow(flow) {
306
296
 
@@ -417,21 +407,23 @@ class AWSDeployer {
417
407
  triggers = [];
418
408
  params.events.forEach(e => {
419
409
  switch(e.source) {
420
- case "api": triggers.push({"api": {"apiId": e.api, "stage": e.stage, "parentId": e.parentId, "resource": e.resource, "authorizerId": e.authorizerId}});
421
- break;
422
- case "sns": triggers.push({"sns": {"topicArn": e.topic}});
423
- break;
424
- case "sqs": triggers.push({"sqs": {"queueArn": e.queueArn, "batchSize": e.batchSize}});
425
- break;
426
- case "dynamodb": triggers.push({"dynamodb": {"streamArn": e.stream, "startingPosition": e.startingPosition, "batchSize": e.batchSize, "batchWindow": e.batchWindow}});
427
- break;
428
- case "kinesis": triggers.push({"kinesis": {"streamArn": e.stream, "startingPosition": e.startingPosition, "batchSize": e.batchSize, "batchWindow": e.batchWindow}});
429
- break;
430
- case "s3": triggers.push({"s3": {"bucket": e.bucket, "eventType": e.eventType, "prefix": e.prefix, "suffix": e.suffix}});
431
- break;
432
- case "cwevents": triggers.push({"event": {"expression": e.expression, "reference": e.reference, "name": e.name}});
433
- break;
434
- }
410
+ case "api": triggers.push({"api": {"apiId": e.api, "stage": e.stage, "parentId": e.parentId, "resource": e.resource, "authorizerId": e.authorizerId}});
411
+ break;
412
+ case "websocket": triggers.push({"websocket": {"apiId": e.apiId, "stage": e.stage}});
413
+ break;
414
+ case "sns": triggers.push({"sns": {"topicArn": e.topic}});
415
+ break;
416
+ case "sqs": triggers.push({"sqs": {"queueArn": e.queueArn, "batchSize": e.batchSize}});
417
+ break;
418
+ case "dynamodb": triggers.push({"dynamodb": {"streamArn": e.stream, "startingPosition": e.startingPosition, "batchSize": e.batchSize, "batchWindow": e.batchWindow}});
419
+ break;
420
+ case "kinesis": triggers.push({"kinesis": {"streamArn": e.stream, "startingPosition": e.startingPosition, "batchSize": e.batchSize, "batchWindow": e.batchWindow}});
421
+ break;
422
+ case "s3": triggers.push({"s3": {"bucket": e.bucket, "eventType": e.eventType, "prefix": e.prefix, "suffix": e.suffix}});
423
+ break;
424
+ case "cwevents": triggers.push({"event": {"expression": e.expression, "reference": e.reference, "name": e.name, "state": e.state}});
425
+ break;
426
+ }
435
427
  })
436
428
  triggers = JSON.stringify(triggers);
437
429
  };
@@ -484,7 +476,6 @@ class AWSDeployer {
484
476
  this.log(` ${this.chalk('#F5DEB3', 'AWS region:')} ${this.chalk('whiteBright', AWS.config.region)}`, false);
485
477
 
486
478
  const settings = this.prepare(projectInfo.projectDir, projectInfo.projectFlowName, params.functionName, params.description);
487
- const nodes = await this.prepareNodes(this.loadJsonFile(path.join(projectInfo.projectDir, projectInfo.projectFlowName)));
488
479
 
489
480
  settings.deploymentBucketName = await this.prepareS3Bucket(
490
481
  settings.flowName
@@ -496,7 +487,9 @@ class AWSDeployer {
496
487
  args["bucket-name"] = settings.deploymentBucketName;
497
488
  args["project-directory"] = projectInfo.projectDir;
498
489
  args["flow-file-name"] = projectInfo.projectFlowName;
490
+ args["zip-file-name"] = settings.zipFileName;
499
491
 
492
+ console.log(`args: ${JSON.stringify(args)}`);
500
493
  const scriptFileName = exp("cloudformation", "aws", args);
501
494
  this.log(`Cloudformation script has been created: ${scriptFileName}`);
502
495
 
@@ -517,8 +510,7 @@ class AWSDeployer {
517
510
  args["flow-file-name"] = projectInfo.projectFlowName;
518
511
  args["zip-file-name"] = settings.zipFileName;
519
512
 
520
- const buildFileName = await build("aws", args);
521
- return buildFileName;
513
+ await build("aws", args);
522
514
  }
523
515
 
524
516
  /*
@@ -565,7 +557,9 @@ class AWSDeployer {
565
557
  await this.cf
566
558
  .waitFor('stackCreateComplete', { StackName: stackParams.StackName })
567
559
  .promise();
560
+
568
561
  } catch (error) {
562
+
569
563
  if (error.code == 'AlreadyExistsException') {
570
564
  stack = await this.cf.updateStack(stackParams).promise();
571
565
  this.log('Waiting for stack update complete...');
@@ -577,6 +571,7 @@ class AWSDeployer {
577
571
  })
578
572
  .promise();
579
573
  } catch (error) {
574
+
580
575
  await this.describeStackEvents(
581
576
  stackParams.StackName,
582
577
  deploymentStartTimestamp
@@ -595,95 +590,6 @@ class AWSDeployer {
595
590
  return this.describeStack(stackParams.StackName);
596
591
  }
597
592
 
598
- async runTriggers(params, settings, lambdaArn) {
599
- let response = {};
600
-
601
- if (params.events) {
602
- this.log('Adding flow triggers ...');
603
-
604
- for (var i = 0; i < params.events.length; i++) {
605
- if (params.events[i].source === 's3') {
606
- await this.addS3Event(
607
- params.events[i],
608
- settings.functionName,
609
- lambdaArn
610
- );
611
- } else if (params.events[i].source === 'sns') {
612
- await this.addSNSEvent(
613
- params.events[i],
614
- settings.functionName,
615
- lambdaArn
616
- );
617
- } else if (params.events[i].source === 'cwevents') {
618
- await this.addCWEvent(
619
- params.events[i],
620
- settings.functionName,
621
- lambdaArn
622
- );
623
- } else if (params.events[i].source === 'cwlogs') {
624
- await this.addCWLogsEvent(
625
- params.events[i],
626
- settings.functionName,
627
- lambdaArn
628
- );
629
- } else if (params.events[i].source === 'cognito') {
630
- await this.addCognitoEvent(
631
- params.events[i],
632
- settings.functionName,
633
- lambdaArn
634
- );
635
- } else if (params.events[i].source === 'alexa') {
636
- await this.addAlexaEvent(
637
- params.events[i],
638
- settings.functionName,
639
- lambdaArn
640
- );
641
- } else if (params.events[i].source === 'codecommit') {
642
- await this.addCodeCommitEvent(
643
- params.events[i],
644
- settings.functionName,
645
- lambdaArn
646
- );
647
- } else if (params.events[i].source === 'iot') {
648
- var rule = await this.iot.addTrigger(
649
- params.events[i],
650
- settings.functionName,
651
- lambdaArn
652
- );
653
- if (rule) {
654
- await this.addLambdaPermission(
655
- 'iot.amazonaws.com',
656
- settings.functionName,
657
- null,
658
- rule.ruleArn
659
- );
660
- }
661
- } else if (params.events[i].source === 'api') {
662
- const newApiId = await this.apiGateway.addTrigger(
663
- params.events[i],
664
- settings.functionName,
665
- lambdaArn
666
- );
667
-
668
- response.apiId = newApiId? newApiId: params.events[i].api;
669
- response.stage = params.events[i].stage;
670
-
671
- //arn:aws:lambda:ap-southeast-2:640233474616:function:kumologica-aws-inbound-test-flow-lambda
672
- const lambdaArnParts = lambdaArn.split(':');
673
- const apiArn = `arn:aws:execute-api:${lambdaArnParts[3]}:${lambdaArnParts[4]}:${params.events[i].api}/*/*/{proxy+}`;
674
- await this.addLambdaPermission(
675
- 'apigateway.amazonaws.com',
676
- settings.functionName,
677
- null,
678
- apiArn
679
- );
680
- }
681
- }
682
- this.log(`${this.chalk('greenBright', 'All triggers added successfully:')}`);
683
- }
684
- return response;
685
- }
686
-
687
593
  async describeStack(stackName) {
688
594
  return this.cf.describeStacks({ StackName: stackName }).promise();
689
595
  }
@@ -693,10 +599,17 @@ class AWSDeployer {
693
599
  */
694
600
  async describeStackEvents(stackName, deploymentStartTimestamp) {
695
601
  this.log('Calling describe stack events...');
602
+ let events;
696
603
 
697
- const events = await this.cf
604
+ try {
605
+ events = await this.cf
698
606
  .describeStackEvents({ StackName: stackName })
699
607
  .promise();
608
+ } catch (error) {
609
+ //this.log(`de: ${error}`);
610
+ // may throw stack does not exists for the first ever call
611
+ }
612
+
700
613
  if (!events || events == undefined) {
701
614
  return;
702
615
  }
@@ -740,157 +653,6 @@ class AWSDeployer {
740
653
  fs.outputFileSync(path.join(baseDir, fileName), content, 'utf-8');
741
654
  }
742
655
 
743
- async addLambdaPermission(
744
- principal,
745
- lambdaName,
746
- sourceAccount,
747
- sourceArn,
748
- eventSourceToken
749
- ) {
750
- var request = {
751
- Action: 'lambda:InvokeFunction',
752
- FunctionName: lambdaName,
753
- Principal: principal,
754
- SourceAccount: sourceAccount,
755
- SourceArn: sourceArn,
756
- EventSourceToken: eventSourceToken,
757
- StatementId: `${lambdaName}-${Date.now()}`,
758
- };
759
-
760
- // wait for response, the subsequent calls require permissions to be present.
761
- await this.lambdaApi.addPermission(request).promise();
762
- }
763
-
764
- async addS3Event(event, lambdaName, lambdaArn) {
765
- if (!event.bucket) {
766
- throw Error(`Missing Trigger Parameter: Bucket Name.`);
767
- }
768
-
769
- this.log(
770
- `Setting lambda execution permissions for bucket ${event.bucket} ...`
771
- );
772
- await this.addLambdaPermission(
773
- 's3.amazonaws.com',
774
- lambdaName,
775
- event.sourceAccount,
776
- `arn:aws:s3:::${event.bucket}`
777
- );
778
-
779
- await this.s3.bucketNotificationConfiguration(
780
- lambdaArn,
781
- event.bucket,
782
- event.eventType,
783
- event.prefix,
784
- event.suffix
785
- );
786
- }
787
-
788
- async addAlexaEvent(event, lambdaName, lambdaArn) {
789
- this.log(`Setting configuration for alexa skill id ${event.skillID} ...`);
790
- await this.addLambdaPermission(
791
- 'alexa-appkit.amazon.com',
792
- lambdaName,
793
- null,
794
- null,
795
- event.skillID
796
- );
797
- }
798
-
799
- async addCodeCommitEvent(event, lambdaName, lambdaArn) {
800
- this.log(
801
- `Setting configuration for code commit repository ${event.repository} ...`
802
- );
803
-
804
- await this.addLambdaPermission(
805
- 'codecommit.amazon.com',
806
- lambdaName,
807
- event.account,
808
- event.repositoryArn
809
- );
810
-
811
- this.log('Adding permissions for lambda to call codecommit.');
812
- await this.codecommit.addLambdaPermissions(event, lambdaArn);
813
- }
814
-
815
- async addSNSEvent(event, lambdaName, lambdaArn) {
816
- await this.addLambdaPermission(
817
- 'sns.amazonaws.com',
818
- lambdaName,
819
- null,
820
- event.topic
821
- );
822
-
823
- this.log(`Setting notification configuration for topic ${event.topic} ...`);
824
- await this.sns.subscribe(event.topic, lambdaArn);
825
- }
826
-
827
- async addCWEvent(event, lambdaName, lambdaArn) {
828
- await this.addLambdaPermission(
829
- 'events.amazonaws.com',
830
- lambdaName,
831
- null,
832
- event.rule
833
- );
834
-
835
- const ruleName = event.rule.split('rule/').pop();
836
-
837
- this.log(
838
- `Setting notification configuration for cloudwatch event ${ruleName} ...`
839
- );
840
-
841
- var params = {
842
- Rule: ruleName,
843
- Targets: [
844
- {
845
- Arn: lambdaArn,
846
- Id: `${lambdaName}`,
847
- },
848
- ],
849
- };
850
-
851
- await this.cwevents.putTargets(params).promise();
852
- }
853
-
854
- /**
855
- * https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatchLogs.html#putSubscriptionFilter-property
856
- *
857
- * @param {*} event
858
- * @param {*} lambdaName
859
- * @param {*} lambdaArn
860
- */
861
- async addCWLogsEvent(event, lambdaName, lambdaArn) {
862
- //await this.addLambdaPermission("events.amazonaws.com",
863
- // lambdaName, null, event.rule);
864
-
865
- /*this.log(`Setting notification configuration for cloudwatch event ${ruleName} ...`);
866
- var params = {
867
- destinationArn: 'STRING_VALUE', // required
868
- filterName: 'STRING_VALUE', // required
869
- filterPattern: 'STRING_VALUE', // required
870
- logGroupName: 'STRING_VALUE', // required
871
- distribution: Random | ByLogStream,
872
- roleArn: 'STRING_VALUE'
873
- };*/
874
- await this.cwLogs.putSubscriptionFilter(params).promise();
875
- }
876
-
877
- async addCognitoEvent(event, lambdaName, lambdaArn) {
878
- await this.addLambdaPermission(
879
- 'cognito-idp.amazonaws.com',
880
- lambdaName,
881
- null,
882
- event.identityPool
883
- );
884
-
885
- const ruleName = event.rule.split('rule/').pop();
886
-
887
- // TODO: add cognito implementation
888
- //this.log(`Setting notification configuration for cloudwatch event ${ruleName} ...`);
889
- var params = {};
890
-
891
- await this.cognito.updateUserPool(params).promise();
892
- }
893
-
894
656
  async listServices(type, profile) {
895
657
  if (!profile) {
896
658
  throw new Error(
@@ -929,12 +691,6 @@ class AWSDeployer {
929
691
  case 'iot':
930
692
  res = await this.iot.listTopicRules();
931
693
  break;
932
- case 'alexa':
933
- res = await this.alexa.listSkills();
934
- break;
935
- case 'codecommit':
936
- res = await this.codecommit.listRepositories();
937
- break;
938
694
  case 'iamroles':
939
695
  res = await this.iam.listRoles();
940
696
  break;