@webda/aws 2.0.0-beta.3 → 2.1.0
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/deployers/cloudformation.d.ts +3 -3
- package/lib/deployers/cloudformation.js +673 -694
- package/lib/deployers/cloudformation.js.map +1 -1
- package/lib/deployers/cloudformation.spec.js +428 -477
- package/lib/deployers/cloudformation.spec.js.map +1 -1
- package/lib/deployers/index.js +282 -342
- package/lib/deployers/index.js.map +1 -1
- package/lib/deployers/index.spec.d.ts +1 -1
- package/lib/deployers/index.spec.js +445 -510
- package/lib/deployers/index.spec.js.map +1 -1
- package/lib/deployers/lambda-entrypoint.js +4 -16
- package/lib/deployers/lambda-entrypoint.js.map +1 -1
- package/lib/deployers/lambdapackager.d.ts +1 -1
- package/lib/deployers/lambdapackager.js +14 -53
- package/lib/deployers/lambdapackager.js.map +1 -1
- package/lib/deployers/lambdapackager.spec.js +25 -61
- package/lib/deployers/lambdapackager.spec.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -17
- package/lib/index.js.map +1 -1
- package/lib/index.spec.d.ts +1 -1
- package/lib/index.spec.js +28 -75
- package/lib/index.spec.js.map +1 -1
- package/lib/services/aws-mixin.d.ts +2 -0
- package/lib/services/aws-mixin.js +2 -7
- package/lib/services/aws-mixin.js.map +1 -1
- package/lib/services/cloudwatchlogger.d.ts +3 -1
- package/lib/services/cloudwatchlogger.js +63 -104
- package/lib/services/cloudwatchlogger.js.map +1 -1
- package/lib/services/cloudwatchlogger.spec.js +57 -100
- package/lib/services/cloudwatchlogger.spec.js.map +1 -1
- package/lib/services/dynamodb.d.ts +4 -2
- package/lib/services/dynamodb.js +457 -498
- package/lib/services/dynamodb.js.map +1 -1
- package/lib/services/dynamodb.spec.d.ts +2 -2
- package/lib/services/dynamodb.spec.js +231 -302
- package/lib/services/dynamodb.spec.js.map +1 -1
- package/lib/services/index.d.ts +9 -9
- package/lib/services/index.js +8 -24
- package/lib/services/index.js.map +1 -1
- package/lib/services/lambdacaller.d.ts +2 -0
- package/lib/services/lambdacaller.js +15 -29
- package/lib/services/lambdacaller.js.map +1 -1
- package/lib/services/lambdacaller.spec.js +43 -81
- package/lib/services/lambdacaller.spec.js.map +1 -1
- package/lib/services/lambdaserver.js +167 -190
- package/lib/services/lambdaserver.js.map +1 -1
- package/lib/services/lambdaserver.spec.js +266 -354
- package/lib/services/lambdaserver.spec.js.map +1 -1
- package/lib/services/route53.js +112 -137
- package/lib/services/route53.js.map +1 -1
- package/lib/services/route53.spec.js +56 -92
- package/lib/services/route53.spec.js.map +1 -1
- package/lib/services/s3binary.d.ts +6 -2
- package/lib/services/s3binary.js +189 -251
- package/lib/services/s3binary.js.map +1 -1
- package/lib/services/s3binary.spec.js +185 -254
- package/lib/services/s3binary.spec.js.map +1 -1
- package/lib/services/secretsmanager.d.ts +2 -0
- package/lib/services/secretsmanager.js +32 -56
- package/lib/services/secretsmanager.js.map +1 -1
- package/lib/services/secretsmanager.spec.js +50 -93
- package/lib/services/secretsmanager.spec.js.map +1 -1
- package/lib/services/sqsqueue.d.ts +5 -7
- package/lib/services/sqsqueue.js +70 -99
- package/lib/services/sqsqueue.js.map +1 -1
- package/lib/services/sqsqueue.spec.js +95 -145
- package/lib/services/sqsqueue.spec.js.map +1 -1
- package/lib/shell.js +19 -38
- package/lib/shell.js.map +1 -1
- package/package.json +12 -9
- package/webda.module.json +54 -6
|
@@ -1,55 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.CloudWatchLogger = exports.CloudWatchLoggerParameters = void 0;
|
|
36
|
-
const client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
|
|
37
|
-
const core_1 = require("@webda/core");
|
|
38
|
-
const workout_1 = require("@webda/workout");
|
|
39
|
-
const uuid = __importStar(require("uuid"));
|
|
40
|
-
const aws_mixin_1 = require("./aws-mixin");
|
|
1
|
+
import { CloudWatchLogs } from "@aws-sdk/client-cloudwatch-logs";
|
|
2
|
+
import { Service, ServiceParameters } from "@webda/core";
|
|
3
|
+
import { LogFilter } from "@webda/workout";
|
|
4
|
+
import * as uuid from "uuid";
|
|
5
|
+
import { AWSServiceParameters } from "./aws-mixin.js";
|
|
41
6
|
/**
|
|
42
7
|
* Send webda log to CloudWatch
|
|
43
8
|
*/
|
|
44
|
-
class CloudWatchLoggerParameters extends
|
|
9
|
+
export class CloudWatchLoggerParameters extends AWSServiceParameters(ServiceParameters) {
|
|
45
10
|
}
|
|
46
|
-
exports.CloudWatchLoggerParameters = CloudWatchLoggerParameters;
|
|
47
11
|
/**
|
|
48
12
|
* Output log to a CloudWatch Stream
|
|
49
13
|
*
|
|
50
14
|
* @WebdaModda
|
|
51
15
|
*/
|
|
52
|
-
class CloudWatchLogger extends
|
|
16
|
+
export default class CloudWatchLogger extends Service {
|
|
53
17
|
constructor() {
|
|
54
18
|
super(...arguments);
|
|
55
19
|
this._bufferedLogs = [];
|
|
@@ -65,43 +29,38 @@ class CloudWatchLogger extends core_1.Service {
|
|
|
65
29
|
/**
|
|
66
30
|
* @inheritdoc
|
|
67
31
|
*/
|
|
68
|
-
init() {
|
|
69
|
-
|
|
70
|
-
|
|
32
|
+
async init() {
|
|
33
|
+
await super.init();
|
|
34
|
+
this._logGroupName = this.parameters.logGroupName;
|
|
35
|
+
if (!this._logGroupName) {
|
|
36
|
+
throw Error("Require a log group `logGroupName` parameter");
|
|
37
|
+
}
|
|
38
|
+
this._logStreamName = (this.parameters.logStreamNamePrefix || "") + uuid.v4();
|
|
39
|
+
this._cloudwatch = new CloudWatchLogs(this.parameters);
|
|
40
|
+
let res = await this._cloudwatch.describeLogGroups({
|
|
41
|
+
logGroupNamePrefix: this._logGroupName
|
|
71
42
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this._logGroupName = this.parameters.logGroupName;
|
|
75
|
-
if (!this._logGroupName) {
|
|
76
|
-
throw Error("Require a log group `logGroupName` parameter");
|
|
77
|
-
}
|
|
78
|
-
this._logStreamName = (this.parameters.logStreamNamePrefix || "") + uuid.v4();
|
|
79
|
-
this._cloudwatch = new client_cloudwatch_logs_1.CloudWatchLogs(this.parameters);
|
|
80
|
-
let res = yield this._cloudwatch.describeLogGroups({
|
|
81
|
-
logGroupNamePrefix: this._logGroupName
|
|
82
|
-
});
|
|
83
|
-
if (!res.logGroups.length) {
|
|
84
|
-
yield this._cloudwatch.createLogGroup({
|
|
85
|
-
logGroupName: this._logGroupName,
|
|
86
|
-
kmsKeyId: this.parameters.kmsKeyId,
|
|
87
|
-
tags: this.parameters.tags
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
this._logStream = yield this._cloudwatch.createLogStream({
|
|
43
|
+
if (!res.logGroups.length) {
|
|
44
|
+
await this._cloudwatch.createLogGroup({
|
|
91
45
|
logGroupName: this._logGroupName,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this._webda.getWorkerOutput().on("message", (msg) => {
|
|
95
|
-
if (msg.type !== "log") {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if ((0, workout_1.LogFilter)(msg.log.level, this.parameters.logLevel)) {
|
|
99
|
-
this._log(msg.log.level, ...msg.log.args);
|
|
100
|
-
}
|
|
46
|
+
kmsKeyId: this.parameters.kmsKeyId,
|
|
47
|
+
tags: this.parameters.tags
|
|
101
48
|
});
|
|
102
|
-
|
|
103
|
-
|
|
49
|
+
}
|
|
50
|
+
this._logStream = await this._cloudwatch.createLogStream({
|
|
51
|
+
logGroupName: this._logGroupName,
|
|
52
|
+
logStreamName: this._logStreamName
|
|
53
|
+
});
|
|
54
|
+
this._webda.getWorkerOutput().on("message", (msg) => {
|
|
55
|
+
if (msg.type !== "log") {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (LogFilter(msg.log.level, this.parameters.logLevel)) {
|
|
59
|
+
this._log(msg.log.level, ...msg.log.args);
|
|
60
|
+
}
|
|
104
61
|
});
|
|
62
|
+
this._webda.on("Webda.Result", this.sendLogs.bind(this));
|
|
63
|
+
return this;
|
|
105
64
|
}
|
|
106
65
|
/**
|
|
107
66
|
* Send logs to CloudWatch
|
|
@@ -109,31 +68,29 @@ class CloudWatchLogger extends core_1.Service {
|
|
|
109
68
|
* @param copy
|
|
110
69
|
* @returns
|
|
111
70
|
*/
|
|
112
|
-
sendLogs(copy = false) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
});
|
|
71
|
+
async sendLogs(copy = false) {
|
|
72
|
+
if (!this._bufferedLogs.length) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
let toSend;
|
|
76
|
+
if (copy) {
|
|
77
|
+
toSend = Array.from(this._bufferedLogs);
|
|
78
|
+
this._bufferedLogs = [];
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
toSend = this._bufferedLogs;
|
|
82
|
+
}
|
|
83
|
+
let params = {
|
|
84
|
+
logEvents: toSend,
|
|
85
|
+
logGroupName: this._logGroupName,
|
|
86
|
+
logStreamName: this._logStreamName,
|
|
87
|
+
sequenceToken: this._seqToken
|
|
88
|
+
};
|
|
89
|
+
let res = await this._cloudwatch.putLogEvents(params);
|
|
90
|
+
this._seqToken = res.nextSequenceToken;
|
|
91
|
+
if (!copy) {
|
|
92
|
+
this._bufferedLogs = [];
|
|
93
|
+
}
|
|
137
94
|
}
|
|
138
95
|
/**
|
|
139
96
|
* @inheritdoc
|
|
@@ -173,12 +130,14 @@ class CloudWatchLogger extends core_1.Service {
|
|
|
173
130
|
this.parameters.CloudFormation = this.parameters.CloudFormation || {};
|
|
174
131
|
resources[this._name + "LogGroup"] = {
|
|
175
132
|
Type: "AWS::Logs::LogGroup",
|
|
176
|
-
Properties:
|
|
133
|
+
Properties: {
|
|
134
|
+
...this.parameters.CloudFormation.LogGroup,
|
|
135
|
+
LogGroupName: this.parameters.logGroupName
|
|
136
|
+
}
|
|
177
137
|
};
|
|
178
138
|
// Add any Other resources with prefix of the service
|
|
179
139
|
return resources;
|
|
180
140
|
}
|
|
181
141
|
}
|
|
182
|
-
|
|
183
|
-
exports.CloudWatchLogger = CloudWatchLogger;
|
|
142
|
+
export { CloudWatchLogger };
|
|
184
143
|
//# sourceMappingURL=cloudwatchlogger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudwatchlogger.js","sourceRoot":"","sources":["../../src/services/cloudwatchlogger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cloudwatchlogger.js","sourceRoot":"","sources":["../../src/services/cloudwatchlogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,SAAS,EAAiC,MAAM,gBAAgB,CAAC;AAC1E,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;CAYtF;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,gBACnB,SAAQ,OAAU;IADpB;;QASE,kBAAa,GAAU,EAAE,CAAC;IA8H5B,CAAC;IA5HC;;;;OAIG;IACH,cAAc,CAAC,MAAW;QACxB,OAAO,IAAI,0BAA0B,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;QAClD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,MAAM,KAAK,CAAC,8CA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ding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
6
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
32
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
33
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
34
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
35
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
36
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
37
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
const client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
|
|
42
|
-
const mocha_1 = require("@testdeck/mocha");
|
|
43
|
-
const assert = __importStar(require("assert"));
|
|
44
|
-
const index_spec_1 = require("../index.spec");
|
|
45
|
-
let CloudWatchLoggerTest = class CloudWatchLoggerTest extends index_spec_1.WebdaAwsTest {
|
|
7
|
+
import { CloudWatchLogs } from "@aws-sdk/client-cloudwatch-logs";
|
|
8
|
+
import { suite, test } from "@testdeck/mocha";
|
|
9
|
+
import * as assert from "assert";
|
|
10
|
+
import { checkLocalStack, defaultCreds, WebdaAwsTest } from "../index.spec.js";
|
|
11
|
+
let CloudWatchLoggerTest = class CloudWatchLoggerTest extends WebdaAwsTest {
|
|
46
12
|
getTestConfiguration() {
|
|
47
13
|
return process.cwd() + "/test/config-cloudwatch.json";
|
|
48
14
|
}
|
|
49
|
-
before() {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
let cloudwatch = new client_cloudwatch_logs_1.CloudWatchLogs({
|
|
56
|
-
credentials: index_spec_1.defaultCreds,
|
|
57
|
-
endpoint: "http://localhost:4566",
|
|
58
|
-
region: "us-east-1"
|
|
59
|
-
});
|
|
60
|
-
try {
|
|
61
|
-
yield cloudwatch.deleteLogGroup({
|
|
62
|
-
logGroupName: "webda-test"
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
// Skip bad delete
|
|
67
|
-
}
|
|
68
|
-
yield _super.before.call(this);
|
|
69
|
-
this.service = this.getService("CloudWatchLogger");
|
|
70
|
-
assert.notStrictEqual(this.service, undefined);
|
|
15
|
+
async before() {
|
|
16
|
+
await checkLocalStack();
|
|
17
|
+
let cloudwatch = new CloudWatchLogs({
|
|
18
|
+
credentials: defaultCreds,
|
|
19
|
+
endpoint: "http://localhost:4566",
|
|
20
|
+
region: "us-east-1"
|
|
71
21
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
this.webda.log("INFO", "Plop 0", "Test");
|
|
76
|
-
this.webda.log("DEBUG", "Plop 1", "Test");
|
|
77
|
-
this.webda.log("DEBUG", "Plop 2", "Test");
|
|
78
|
-
this.webda.log("DEBUG", "Plop 3", "Test");
|
|
79
|
-
this.webda.getLogger("whatever").logProgressStart("test", 100, "other");
|
|
80
|
-
this.webda.log("DEBUG", "Plop 4", "Test");
|
|
81
|
-
yield this.webda.emitSync("Webda.Result");
|
|
82
|
-
let res = yield this.service._cloudwatch.describeLogStreams({
|
|
22
|
+
try {
|
|
23
|
+
await cloudwatch.deleteLogGroup({
|
|
83
24
|
logGroupName: "webda-test"
|
|
84
25
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
// Skip bad delete
|
|
29
|
+
}
|
|
30
|
+
await super.before();
|
|
31
|
+
this.service = this.getService("CloudWatchLogger");
|
|
32
|
+
assert.notStrictEqual(this.service, undefined);
|
|
33
|
+
}
|
|
34
|
+
async basic() {
|
|
35
|
+
this.webda.log("INFO", "Plop 0", "Test");
|
|
36
|
+
this.webda.log("DEBUG", "Plop 1", "Test");
|
|
37
|
+
this.webda.log("DEBUG", "Plop 2", "Test");
|
|
38
|
+
this.webda.log("DEBUG", "Plop 3", "Test");
|
|
39
|
+
this.webda.getLogger("whatever").logProgressStart("test", 100, "other");
|
|
40
|
+
this.webda.log("DEBUG", "Plop 4", "Test");
|
|
41
|
+
await this.webda.emitSync("Webda.Result");
|
|
42
|
+
let res = await this.service._cloudwatch.describeLogStreams({
|
|
43
|
+
logGroupName: "webda-test"
|
|
89
44
|
});
|
|
45
|
+
assert.strictEqual(res.logStreams.length, 1);
|
|
46
|
+
assert.notStrictEqual(res.logStreams[0].lastEventTimestamp, undefined);
|
|
47
|
+
this.service.getParameters().logGroupName = undefined;
|
|
48
|
+
await assert.rejects(() => this.service.init(), /Require a log group `logGroupName` parameter/);
|
|
90
49
|
}
|
|
91
50
|
aws() {
|
|
92
51
|
assert.deepStrictEqual(this.service.getARNPolicy("plop"), {
|
|
@@ -109,39 +68,37 @@ let CloudWatchLoggerTest = class CloudWatchLoggerTest extends index_spec_1.Webda
|
|
|
109
68
|
this.service.getParameters().CloudFormationSkip = true;
|
|
110
69
|
assert.deepStrictEqual(this.service.getCloudFormation(), {});
|
|
111
70
|
}
|
|
112
|
-
secondRun() {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
logGroupName: "webda-test"
|
|
130
|
-
});
|
|
131
|
-
assert.strictEqual(res.logStreams.length, 1);
|
|
71
|
+
async secondRun() {
|
|
72
|
+
// Update config to use the stepper
|
|
73
|
+
this.service.getParameters().singlePush = true;
|
|
74
|
+
this.webda.log("INFO", "Plop 0", "Test");
|
|
75
|
+
this.webda.log("DEBUG", "Plop 1", "Test");
|
|
76
|
+
await this.sleep(1000);
|
|
77
|
+
let res = await this.service._cloudwatch.describeLogStreams({
|
|
78
|
+
logGroupName: "webda-test"
|
|
79
|
+
});
|
|
80
|
+
assert.strictEqual(res.logStreams.length, 1);
|
|
81
|
+
assert.notStrictEqual(res.logStreams[0].lastEventTimestamp, undefined);
|
|
82
|
+
this.webda.log("DEBUG", "Plop 2", "Test");
|
|
83
|
+
this.webda.log("DEBUG", "Plop 3", "Test");
|
|
84
|
+
this.webda.log("DEBUG", "Plop 4", "Test");
|
|
85
|
+
await this.webda.emitSync("Webda.Result");
|
|
86
|
+
res = await this.service._cloudwatch.describeLogStreams({
|
|
87
|
+
logGroupName: "webda-test"
|
|
132
88
|
});
|
|
89
|
+
assert.strictEqual(res.logStreams.length, 1);
|
|
133
90
|
}
|
|
134
91
|
};
|
|
135
92
|
__decorate([
|
|
136
|
-
|
|
93
|
+
test
|
|
137
94
|
], CloudWatchLoggerTest.prototype, "basic", null);
|
|
138
95
|
__decorate([
|
|
139
|
-
|
|
96
|
+
test
|
|
140
97
|
], CloudWatchLoggerTest.prototype, "aws", null);
|
|
141
98
|
__decorate([
|
|
142
|
-
|
|
99
|
+
test
|
|
143
100
|
], CloudWatchLoggerTest.prototype, "secondRun", null);
|
|
144
101
|
CloudWatchLoggerTest = __decorate([
|
|
145
|
-
|
|
102
|
+
suite
|
|
146
103
|
], CloudWatchLoggerTest);
|
|
147
104
|
//# sourceMappingURL=cloudwatchlogger.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudwatchlogger.spec.js","sourceRoot":"","sources":["../../src/services/cloudwatchlogger.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cloudwatchlogger.spec.js","sourceRoot":"","sources":["../../src/services/cloudwatchlogger.spec.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAI5E,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,YAAY;IAG7C,oBAAoB;QAClB,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,8BAA8B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
|
|
1
1
|
import { DynamoDBDocument } from "@aws-sdk/lib-dynamodb";
|
|
2
2
|
import { CoreModel, Store, StoreFindResult, StoreParameters, WebdaQL } from "@webda/core";
|
|
3
3
|
import { WorkerOutput } from "@webda/workout";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { CloudFormationDeployer } from "../deployers/cloudformation.js";
|
|
5
|
+
import { CloudFormationContributor } from "./index.js";
|
|
6
6
|
declare const DynamoStoreParameters_base: {
|
|
7
7
|
new (...args: any[]): {
|
|
8
8
|
endpoint?: string;
|
|
@@ -13,6 +13,8 @@ declare const DynamoStoreParameters_base: {
|
|
|
13
13
|
};
|
|
14
14
|
region?: string;
|
|
15
15
|
type: string;
|
|
16
|
+
url?: string;
|
|
17
|
+
openapi?: import("@webda/core/lib/router").OpenAPIWebdaDefinition;
|
|
16
18
|
};
|
|
17
19
|
} & typeof StoreParameters;
|
|
18
20
|
/**
|