@digitraffic/common 2024.1.24-3 → 2024.3.11-1
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/dist/__test__/api/handler-factory.test.d.mts +1 -0
- package/dist/__test__/api/handler-factory.test.mjs +43 -0
- package/dist/__test__/api/response.test.d.mts +1 -0
- package/dist/__test__/api/response.test.mjs +86 -0
- package/dist/__test__/imports.test.d.mts +1 -0
- package/dist/__test__/imports.test.mjs +332 -0
- package/dist/__test__/marine/id_utils.test.d.mts +1 -0
- package/dist/__test__/marine/id_utils.test.mjs +44 -0
- package/dist/__test__/promise/promise.test.d.mts +1 -0
- package/dist/__test__/promise/promise.test.mjs +130 -0
- package/dist/__test__/runtime/dt-logger.test.d.mts +1 -0
- package/dist/__test__/runtime/dt-logger.test.mjs +108 -0
- package/dist/__test__/secrets/secret-holder.test.d.mts +1 -0
- package/dist/__test__/secrets/secret-holder.test.mjs +86 -0
- package/dist/__test__/secrets/secret.test.d.mts +1 -0
- package/dist/__test__/secrets/secret.test.mjs +38 -0
- package/dist/__test__/test/httpserver.test.d.mts +1 -0
- package/dist/__test__/test/httpserver.test.mjs +154 -0
- package/dist/__test__/test/mock-ky.test.d.mts +1 -0
- package/dist/__test__/test/mock-ky.test.mjs +46 -0
- package/dist/__test__/types/lambda-response.test.d.mts +1 -0
- package/dist/__test__/types/lambda-response.test.mjs +58 -0
- package/dist/__test__/utils/date-utils.test.d.mts +1 -0
- package/dist/__test__/utils/date-utils.test.mjs +27 -0
- package/dist/__test__/utils/geometry.test.d.mts +1 -0
- package/dist/__test__/utils/geometry.test.mjs +24 -0
- package/dist/__test__/utils/logging.test.d.mts +1 -0
- package/dist/__test__/utils/logging.test.mjs +78 -0
- package/dist/__test__/utils/utils.test.d.mts +1 -0
- package/dist/__test__/utils/utils.test.mjs +43 -0
- package/dist/aws/infra/api/handler-factory.mjs +4 -0
- package/dist/aws/infra/api/integration.d.mts +2 -2
- package/dist/aws/infra/api/integration.mjs +4 -1
- package/dist/aws/infra/api/response.d.mts +1 -1
- package/dist/aws/infra/api/responses.d.mts +1 -1
- package/dist/aws/infra/api/responses.mjs +2 -0
- package/dist/aws/infra/api/static-integration.mjs +1 -1
- package/dist/aws/infra/canaries/canary-alarm.d.mts +1 -1
- package/dist/aws/infra/canaries/canary-alarm.mjs +2 -0
- package/dist/aws/infra/canaries/canary-parameters.mjs +1 -1
- package/dist/aws/infra/canaries/canary-role.mjs +1 -0
- package/dist/aws/infra/canaries/canary.d.mts +2 -2
- package/dist/aws/infra/canaries/canary.mjs +2 -0
- package/dist/aws/infra/canaries/database-canary.d.mts +2 -2
- package/dist/aws/infra/canaries/database-canary.mjs +2 -0
- package/dist/aws/infra/canaries/database-checker.d.mts +1 -1
- package/dist/aws/infra/canaries/database-checker.mjs +7 -1
- package/dist/aws/infra/canaries/url-canary.d.mts +2 -2
- package/dist/aws/infra/canaries/url-canary.mjs +3 -0
- package/dist/aws/infra/canaries/url-checker.d.mts +1 -1
- package/dist/aws/infra/canaries/url-checker.mjs +4 -1
- package/dist/aws/infra/documentation.mjs +5 -1
- package/dist/aws/infra/import-util.d.mts +1 -1
- package/dist/aws/infra/import-util.mjs +4 -3
- package/dist/aws/infra/scheduler.mjs +2 -0
- package/dist/aws/infra/security-rule.d.mts +1 -1
- package/dist/aws/infra/security-rule.mjs +1 -0
- package/dist/aws/infra/sqs-integration.d.mts +1 -1
- package/dist/aws/infra/sqs-integration.mjs +3 -1
- package/dist/aws/infra/sqs-queue.d.mts +1 -1
- package/dist/aws/infra/sqs-queue.mjs +2 -1
- package/dist/aws/infra/stack/lambda-configs.d.mts +4 -4
- package/dist/aws/infra/stack/lambda-configs.mjs +4 -2
- package/dist/aws/infra/stack/monitoredfunction.d.mts +3 -3
- package/dist/aws/infra/stack/monitoredfunction.mjs +23 -18
- package/dist/aws/infra/stack/parameters.mjs +1 -0
- package/dist/aws/infra/stack/rest_apis.d.mts +2 -2
- package/dist/aws/infra/stack/rest_apis.mjs +6 -1
- package/dist/aws/infra/stack/stack-checking-aspect.d.mts +2 -2
- package/dist/aws/infra/stack/stack-checking-aspect.mjs +6 -1
- package/dist/aws/infra/stack/stack.d.mts +5 -5
- package/dist/aws/infra/stack/stack.mjs +9 -0
- package/dist/aws/infra/stack/subscription.mjs +4 -0
- package/dist/aws/infra/stacks/db-dns-stack.d.mts +1 -1
- package/dist/aws/infra/stacks/db-dns-stack.mjs +1 -0
- package/dist/aws/infra/stacks/db-proxy-stack.d.mts +3 -3
- package/dist/aws/infra/stacks/db-proxy-stack.mjs +4 -2
- package/dist/aws/infra/stacks/db-stack.d.mts +3 -3
- package/dist/aws/infra/stacks/db-stack.mjs +11 -7
- package/dist/aws/infra/stacks/intra-stack-configuration.d.mts +1 -1
- package/dist/aws/infra/stacks/network-stack.d.mts +2 -2
- package/dist/aws/infra/stacks/network-stack.mjs +8 -0
- package/dist/aws/infra/usage-plans.d.mts +1 -1
- package/dist/aws/infra/usage-plans.mjs +1 -0
- package/dist/aws/runtime/apikey.d.mts +2 -2
- package/dist/aws/runtime/apikey.mjs +2 -2
- package/dist/aws/runtime/digitraffic-integration-response.d.mts +1 -1
- package/dist/aws/runtime/dt-logger.mjs +6 -2
- package/dist/aws/runtime/messaging.d.mts +2 -2
- package/dist/aws/runtime/messaging.mjs +5 -4
- package/dist/aws/runtime/s3.d.mts +4 -2
- package/dist/aws/runtime/s3.mjs +15 -10
- package/dist/aws/runtime/secrets/dbsecret.d.mts +1 -1
- package/dist/aws/runtime/secrets/proxy-holder.mjs +1 -0
- package/dist/aws/runtime/secrets/rds-holder.mjs +1 -0
- package/dist/aws/runtime/secrets/secret-holder.d.mts +1 -1
- package/dist/aws/runtime/secrets/secret-holder.mjs +6 -1
- package/dist/aws/runtime/secrets/secret.mjs +5 -6
- package/dist/aws/types/errors.mjs +1 -0
- package/dist/aws/types/lambda-response.mjs +5 -0
- package/dist/aws/types/model-with-reference.mjs +1 -1
- package/dist/database/cached.d.mts +1 -1
- package/dist/database/database.mjs +1 -0
- package/dist/database/last-updated.d.mts +1 -1
- package/dist/test/db-testutils.d.mts +1 -1
- package/dist/test/db-testutils.mjs +1 -1
- package/dist/test/httpserver.mjs +7 -3
- package/dist/test/mock-ky.d.mts +2 -0
- package/dist/test/mock-ky.mjs +15 -0
- package/dist/test/secrets-manager.d.mts +3 -2
- package/dist/test/secrets-manager.mjs +14 -16
- package/dist/test/testutils.mjs +1 -1
- package/dist/types/http-error.mjs +1 -0
- package/dist/types/nullable.d.mts +1 -1
- package/dist/utils/api-model.d.mts +2 -2
- package/dist/utils/api-model.mjs +1 -1
- package/dist/utils/geojson-types.d.mts +1 -1
- package/dist/utils/geojson-types.mjs +4 -2
- package/dist/utils/geometry.d.mts +1 -1
- package/dist/utils/geometry.mjs +3 -0
- package/dist/utils/logging.mjs +2 -2
- package/dist/utils/retry.d.mts +2 -2
- package/dist/utils/retry.mjs +2 -2
- package/dist/utils/slack.mjs +4 -3
- package/dist/utils/utils.d.mts +2 -2
- package/package.json +25 -15
- package/src/@types/geojson-validation/index.d.mts +0 -4
- package/src/aws/infra/api/handler-factory.mts +0 -86
- package/src/aws/infra/api/integration.mts +0 -147
- package/src/aws/infra/api/response.mts +0 -165
- package/src/aws/infra/api/responses.mts +0 -127
- package/src/aws/infra/api/static-integration.mts +0 -108
- package/src/aws/infra/canaries/Synthetics.d.mts +0 -21
- package/src/aws/infra/canaries/canary-alarm.mts +0 -33
- package/src/aws/infra/canaries/canary-keys.mts +0 -3
- package/src/aws/infra/canaries/canary-parameters.mts +0 -19
- package/src/aws/infra/canaries/canary-role.mts +0 -73
- package/src/aws/infra/canaries/canary.mts +0 -44
- package/src/aws/infra/canaries/database-canary.mts +0 -98
- package/src/aws/infra/canaries/database-checker.mts +0 -163
- package/src/aws/infra/canaries/url-canary.mts +0 -98
- package/src/aws/infra/canaries/url-checker.mts +0 -388
- package/src/aws/infra/documentation.mts +0 -142
- package/src/aws/infra/import-util.mts +0 -57
- package/src/aws/infra/scheduler.mts +0 -59
- package/src/aws/infra/security-rule.mts +0 -38
- package/src/aws/infra/sqs-integration.mts +0 -106
- package/src/aws/infra/sqs-queue.mts +0 -162
- package/src/aws/infra/stack/lambda-configs.mts +0 -135
- package/src/aws/infra/stack/monitoredfunction.mts +0 -352
- package/src/aws/infra/stack/parameters.mts +0 -74
- package/src/aws/infra/stack/rest_apis.mts +0 -322
- package/src/aws/infra/stack/stack-checking-aspect.mts +0 -233
- package/src/aws/infra/stack/stack.mts +0 -144
- package/src/aws/infra/stack/subscription.mts +0 -58
- package/src/aws/infra/stacks/db-dns-stack.mts +0 -77
- package/src/aws/infra/stacks/db-proxy-stack.mts +0 -134
- package/src/aws/infra/stacks/db-stack.mts +0 -292
- package/src/aws/infra/stacks/intra-stack-configuration.mts +0 -6
- package/src/aws/infra/stacks/network-stack.mts +0 -76
- package/src/aws/infra/usage-plans.mts +0 -50
- package/src/aws/runtime/apikey.mts +0 -9
- package/src/aws/runtime/digitraffic-integration-response.mts +0 -35
- package/src/aws/runtime/dt-logger-default.mts +0 -11
- package/src/aws/runtime/dt-logger.mts +0 -184
- package/src/aws/runtime/environment.mts +0 -22
- package/src/aws/runtime/messaging.mts +0 -26
- package/src/aws/runtime/s3.mts +0 -44
- package/src/aws/runtime/secrets/dbsecret.mts +0 -31
- package/src/aws/runtime/secrets/node-ttl.d.mts +0 -12
- package/src/aws/runtime/secrets/proxy-holder.mts +0 -34
- package/src/aws/runtime/secrets/rds-holder.mts +0 -34
- package/src/aws/runtime/secrets/secret-holder.mts +0 -106
- package/src/aws/runtime/secrets/secret.mts +0 -58
- package/src/aws/types/errors.mts +0 -14
- package/src/aws/types/lambda-response.mts +0 -100
- package/src/aws/types/mediatypes.mts +0 -12
- package/src/aws/types/model-with-reference.mts +0 -8
- package/src/aws/types/proxytypes.mts +0 -27
- package/src/aws/types/tags.mts +0 -3
- package/src/database/cached.mts +0 -64
- package/src/database/database.mts +0 -107
- package/src/database/last-updated.mts +0 -103
- package/src/database/models.mts +0 -7
- package/src/index.mts +0 -2
- package/src/marine/id_utils.mts +0 -30
- package/src/marine/rtz.mts +0 -57
- package/src/test/asserter.mts +0 -58
- package/src/test/db-testutils.mts +0 -52
- package/src/test/httpserver.mts +0 -111
- package/src/test/secrets-manager.mts +0 -37
- package/src/test/testutils.mts +0 -39
- package/src/types/async-timeout-error.mts +0 -5
- package/src/types/aws-env.mts +0 -3
- package/src/types/either.mts +0 -9
- package/src/types/http-error.mts +0 -8
- package/src/types/input-error.mts +0 -2
- package/src/types/language.mts +0 -3
- package/src/types/nullable.mts +0 -21
- package/src/types/traffictype.mts +0 -8
- package/src/types/urn.mts +0 -1
- package/src/types/util-types.mts +0 -10
- package/src/types/validator.mts +0 -10
- package/src/utils/api-model.mts +0 -133
- package/src/utils/base64.mts +0 -16
- package/src/utils/date-utils.mts +0 -53
- package/src/utils/geojson-types.mts +0 -22
- package/src/utils/geometry.mts +0 -171
- package/src/utils/logging.mts +0 -75
- package/src/utils/retry.mts +0 -200
- package/src/utils/slack.mts +0 -26
- package/src/utils/utils.mts +0 -184
@@ -0,0 +1,43 @@
|
|
1
|
+
import * as ArrayUtils from "../../utils/utils.mjs";
|
2
|
+
describe("ArrayUtils", () => {
|
3
|
+
test("bothArraysHasSameValues", () => {
|
4
|
+
expect(ArrayUtils.bothArraysHasSameValues([], [])).toEqual(true);
|
5
|
+
expect(ArrayUtils.bothArraysHasSameValues(["a"], ["a"])).toEqual(true);
|
6
|
+
expect(ArrayUtils.bothArraysHasSameValues(["a"], ["a", "a"])).toEqual(true);
|
7
|
+
expect(ArrayUtils.bothArraysHasSameValues(["a", "a"], ["a", "a"])).toEqual(true);
|
8
|
+
expect(ArrayUtils.bothArraysHasSameValues(null, null)).toEqual(true);
|
9
|
+
expect(ArrayUtils.bothArraysHasSameValues(undefined, undefined)).toEqual(true);
|
10
|
+
expect(ArrayUtils.bothArraysHasSameValues(null, undefined)).toEqual(true);
|
11
|
+
expect(ArrayUtils.bothArraysHasSameValues(["a"], undefined)).toEqual(false);
|
12
|
+
expect(ArrayUtils.bothArraysHasSameValues(["a"], null)).toEqual(false);
|
13
|
+
/* eslint-enable */
|
14
|
+
expect(ArrayUtils.bothArraysHasSameValues(["a", "b"], ["a", "a"])).toEqual(false);
|
15
|
+
expect(ArrayUtils.bothArraysHasSameValues(["a", "a", "a"], ["a", "b", "c"])).toEqual(false);
|
16
|
+
const o1 = { a: 1, b: 2 };
|
17
|
+
const o2 = { a: 1, b: 2 };
|
18
|
+
// Objects are references to same
|
19
|
+
expect(ArrayUtils.bothArraysHasSameValues([o1], [o1])).toEqual(true);
|
20
|
+
// Object's are not the same but the contents are the same
|
21
|
+
expect(ArrayUtils.bothArraysHasSameValues([o1], [o2])).toEqual(false);
|
22
|
+
});
|
23
|
+
test("getFirst - empty throws", () => {
|
24
|
+
expect(() => {
|
25
|
+
ArrayUtils.getFirst([]);
|
26
|
+
}).toThrow();
|
27
|
+
});
|
28
|
+
test("getFirst - two objects", () => {
|
29
|
+
expect(ArrayUtils.getFirst([1, 2])).toEqual(1);
|
30
|
+
});
|
31
|
+
test("getFirst - two objects with sort function", () => {
|
32
|
+
expect(ArrayUtils.getFirst([1, 2], (a) => -a)).toEqual(2);
|
33
|
+
});
|
34
|
+
test("getLast - empty throws", () => {
|
35
|
+
expect(() => {
|
36
|
+
ArrayUtils.getLast([]);
|
37
|
+
}).toThrow();
|
38
|
+
});
|
39
|
+
test("getLast - two objects", () => {
|
40
|
+
expect(ArrayUtils.getLast([1, 2])).toEqual(2);
|
41
|
+
});
|
42
|
+
});
|
43
|
+
//# sourceMappingURL=utils.test.mjs.map
|
@@ -1,4 +1,6 @@
|
|
1
1
|
import { getEnvVariableOrElse } from "../../../utils/utils.mjs";
|
2
|
+
import { DtLogger } from "../../runtime/dt-logger.mjs";
|
3
|
+
import { LambdaResponse } from "../../types/lambda-response.mjs";
|
2
4
|
const functionName = getEnvVariableOrElse("AWS_LAMBDA_FUNCTION_NAME", "test");
|
3
5
|
/**
|
4
6
|
* Factory class for creating lambda-handler functions. You can set functionality to handle logging and error-handling,
|
@@ -10,6 +12,8 @@ const functionName = getEnvVariableOrElse("AWS_LAMBDA_FUNCTION_NAME", "test");
|
|
10
12
|
* creating handler-functions for your lambdas.
|
11
13
|
*/
|
12
14
|
export class HandlerFactory {
|
15
|
+
loggingHandler;
|
16
|
+
errorHandler;
|
13
17
|
constructor() {
|
14
18
|
this.loggingHandler = async (method) => {
|
15
19
|
const start = Date.now();
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { IntegrationResponse, LambdaIntegration } from "aws-cdk-lib/aws-apigateway";
|
2
|
-
import { IFunction } from "aws-cdk-lib/aws-lambda";
|
1
|
+
import { type IntegrationResponse, LambdaIntegration } from "aws-cdk-lib/aws-apigateway";
|
2
|
+
import type { IFunction } from "aws-cdk-lib/aws-lambda";
|
3
3
|
import { MediaType } from "../../types/mediatypes.mjs";
|
4
4
|
type ParameterType = "path" | "querystring" | "multivaluequerystring" | "context" | "header";
|
5
5
|
interface ApiParameter {
|
@@ -2,8 +2,11 @@ import { LambdaIntegration, PassthroughBehavior, } from "aws-cdk-lib/aws-apigate
|
|
2
2
|
import { MediaType } from "../../types/mediatypes.mjs";
|
3
3
|
import { DigitrafficIntegrationResponse } from "../../runtime/digitraffic-integration-response.mjs";
|
4
4
|
export class DigitrafficIntegration {
|
5
|
+
lambda;
|
6
|
+
mediaType;
|
7
|
+
parameters = [];
|
8
|
+
sunset;
|
5
9
|
constructor(lambda, mediaType = MediaType.TEXT_PLAIN, sunset) {
|
6
|
-
this.parameters = [];
|
7
10
|
this.lambda = lambda;
|
8
11
|
this.mediaType = mediaType;
|
9
12
|
this.sunset = sunset;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { MediaType } from "../../types/mediatypes.mjs";
|
2
|
-
import { JsonSchema, MethodResponse, type IModel } from "aws-cdk-lib/aws-apigateway";
|
2
|
+
import { type JsonSchema, type MethodResponse, type IModel } from "aws-cdk-lib/aws-apigateway";
|
3
3
|
/**
|
4
4
|
* This is velocity-script, that assumes the response to be LambdaResponse(status and body).
|
5
5
|
* It will always return the body and status, but if status in something else than 200 OK the content-type
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { LambdaIntegration, MethodResponse, IntegrationResponse, PassthroughBehavior, type IModel } from "aws-cdk-lib/aws-apigateway";
|
1
|
+
import { LambdaIntegration, type MethodResponse, type IntegrationResponse, PassthroughBehavior, type IModel } from "aws-cdk-lib/aws-apigateway";
|
2
2
|
import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
|
3
3
|
import { MediaType } from "../../types/mediatypes.mjs";
|
4
4
|
export declare const RESPONSE_200_OK: IntegrationResponse;
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { InternalServerErrorResponseTemplate, XmlResponseTemplate, NotFoundResponseTemplate, BadRequestResponseTemplate, } from "./response.mjs";
|
2
2
|
import { LambdaIntegration, PassthroughBehavior } from "aws-cdk-lib/aws-apigateway";
|
3
|
+
import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
|
3
4
|
import { BAD_REQUEST_MESSAGE, ERROR_MESSAGE, NOT_FOUND_MESSAGE, } from "../../types/errors.mjs";
|
5
|
+
import { MediaType } from "../../types/mediatypes.mjs";
|
4
6
|
/// @deprecated
|
5
7
|
export const RESPONSE_200_OK = {
|
6
8
|
statusCode: "200",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { MockIntegration, PassthroughBehavior, } from "aws-cdk-lib/aws-apigateway";
|
1
|
+
import { MockIntegration, PassthroughBehavior, Resource, } from "aws-cdk-lib/aws-apigateway";
|
2
2
|
import { MediaType } from "../../types/mediatypes.mjs";
|
3
3
|
import { RESPONSE_CORS_INTEGRATION } from "./responses.mjs";
|
4
4
|
const INTEGRATION_RESPONSE_200 = `{
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Construct } from "constructs";
|
2
|
-
import { CanaryParameters } from "./canary-parameters.mjs";
|
2
|
+
import type { CanaryParameters } from "./canary-parameters.mjs";
|
3
3
|
import { Canary } from "aws-cdk-lib/aws-synthetics";
|
4
4
|
export declare class CanaryAlarm {
|
5
5
|
constructor(stack: Construct, canary: Canary, params: CanaryParameters);
|
@@ -1,4 +1,6 @@
|
|
1
|
+
import { Construct } from "constructs";
|
1
2
|
import { Alarm, ComparisonOperator } from "aws-cdk-lib/aws-cloudwatch";
|
3
|
+
import { Canary } from "aws-cdk-lib/aws-synthetics";
|
2
4
|
import { SnsAction } from "aws-cdk-lib/aws-cloudwatch-actions";
|
3
5
|
import { Topic } from "aws-cdk-lib/aws-sns";
|
4
6
|
export class CanaryAlarm {
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
import { Schedule } from "aws-cdk-lib/aws-synthetics";
|
2
2
|
//# sourceMappingURL=canary-parameters.mjs.map
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Canary } from "aws-cdk-lib/aws-synthetics";
|
2
2
|
import { Role } from "aws-cdk-lib/aws-iam";
|
3
|
-
import { CanaryParameters } from "./canary-parameters.mjs";
|
3
|
+
import type { CanaryParameters } from "./canary-parameters.mjs";
|
4
4
|
import { Construct } from "constructs";
|
5
|
-
import { LambdaEnvironment } from "../stack/lambda-configs.mjs";
|
5
|
+
import type { LambdaEnvironment } from "../stack/lambda-configs.mjs";
|
6
6
|
export declare class DigitrafficCanary extends Canary {
|
7
7
|
constructor(scope: Construct, canaryName: string, role: Role, params: CanaryParameters, environmentVariables: LambdaEnvironment);
|
8
8
|
}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { Duration } from "aws-cdk-lib";
|
2
2
|
import { AssetCode, Canary, Runtime, Schedule, Test, } from "aws-cdk-lib/aws-synthetics";
|
3
|
+
import { Role } from "aws-cdk-lib/aws-iam";
|
3
4
|
import { CanaryAlarm } from "./canary-alarm.mjs";
|
5
|
+
import { Construct } from "constructs";
|
4
6
|
export class DigitrafficCanary extends Canary {
|
5
7
|
constructor(scope, canaryName, role, params, environmentVariables) {
|
6
8
|
super(scope, canaryName, {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Role } from "aws-cdk-lib/aws-iam";
|
2
|
-
import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
3
|
-
import { CanaryParameters } from "./canary-parameters.mjs";
|
2
|
+
import type { ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
3
|
+
import type { CanaryParameters } from "./canary-parameters.mjs";
|
4
4
|
import { DigitrafficCanary } from "./canary.mjs";
|
5
5
|
import { DigitrafficStack } from "../stack/stack.mjs";
|
6
6
|
export declare class DatabaseCanary extends DigitrafficCanary {
|
@@ -1,7 +1,9 @@
|
|
1
|
+
import { Role } from "aws-cdk-lib/aws-iam";
|
1
2
|
import { CfnCanary } from "aws-cdk-lib/aws-synthetics";
|
2
3
|
import { Schedule } from "aws-cdk-lib/aws-events";
|
3
4
|
import { Duration } from "aws-cdk-lib";
|
4
5
|
import { DigitrafficCanary } from "./canary.mjs";
|
6
|
+
import { DigitrafficStack } from "../stack/stack.mjs";
|
5
7
|
export class DatabaseCanary extends DigitrafficCanary {
|
6
8
|
constructor(stack, role, secret, params) {
|
7
9
|
const canaryName = `${params.name}-db`;
|
@@ -5,6 +5,9 @@ import { getEnvVariable } from "../../../utils/utils.mjs";
|
|
5
5
|
import { logger } from "../../runtime/dt-logger-default.mjs";
|
6
6
|
import synthetics from "Synthetics";
|
7
7
|
class DatabaseCheck {
|
8
|
+
name;
|
9
|
+
sql;
|
10
|
+
failed;
|
8
11
|
constructor(name, sql) {
|
9
12
|
this.name = name;
|
10
13
|
this.sql = sql;
|
@@ -12,6 +15,8 @@ class DatabaseCheck {
|
|
12
15
|
}
|
13
16
|
}
|
14
17
|
class CountDatabaseCheck extends DatabaseCheck {
|
18
|
+
minCount;
|
19
|
+
maxCount;
|
15
20
|
constructor(name, sql, minCount, maxCount) {
|
16
21
|
super(name, sql);
|
17
22
|
if (!sql.toLowerCase().includes("select") ||
|
@@ -52,8 +57,9 @@ const stepConfig = {
|
|
52
57
|
* sql must be structured as "select count(*) from <table> where <something>".
|
53
58
|
*/
|
54
59
|
export class DatabaseCountChecker {
|
60
|
+
credentialsFunction;
|
61
|
+
checks = [];
|
55
62
|
constructor(credentialsFunction) {
|
56
|
-
this.checks = [];
|
57
63
|
this.credentialsFunction = credentialsFunction;
|
58
64
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
59
65
|
synthetics.getConfiguration().disableRequestMetrics();
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { Role } from "aws-cdk-lib/aws-iam";
|
2
|
-
import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
2
|
+
import type { ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
3
3
|
import { DigitrafficRestApi } from "../stack/rest_apis.mjs";
|
4
4
|
import { DigitrafficStack } from "../stack/stack.mjs";
|
5
5
|
import { DigitrafficCanary } from "./canary.mjs";
|
6
|
-
import { CanaryParameters } from "./canary-parameters.mjs";
|
6
|
+
import type { CanaryParameters } from "./canary-parameters.mjs";
|
7
7
|
export interface UrlCanaryParameters extends CanaryParameters {
|
8
8
|
readonly hostname: string;
|
9
9
|
readonly apiKeyId: string;
|
@@ -1,4 +1,7 @@
|
|
1
|
+
import { Role } from "aws-cdk-lib/aws-iam";
|
1
2
|
import { CfnCanary } from "aws-cdk-lib/aws-synthetics";
|
3
|
+
import { DigitrafficRestApi } from "../stack/rest_apis.mjs";
|
4
|
+
import { DigitrafficStack } from "../stack/stack.mjs";
|
2
5
|
import { DigitrafficCanary } from "./canary.mjs";
|
3
6
|
import { ENV_API_KEY, ENV_HOSTNAME, ENV_SECRET } from "./canary-keys.mjs";
|
4
7
|
export class UrlCanary extends DigitrafficCanary {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
2
2
|
import { IncomingMessage } from "http";
|
3
3
|
import { MediaType } from "../../types/mediatypes.mjs";
|
4
|
-
import { FeatureCollection } from "geojson";
|
4
|
+
import type { FeatureCollection } from "geojson";
|
5
5
|
export declare const API_KEY_HEADER = "x-api-key";
|
6
6
|
type CheckerFunction = (Res: IncomingMessage) => Promise<void>;
|
7
7
|
type JsonCheckerFunction<T> = (json: T, body: string, message: IncomingMessage) => Promise<void>;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { IncomingMessage } from "http";
|
1
2
|
import { Asserter } from "../../../test/asserter.mjs";
|
2
3
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
3
4
|
import synthetics from "Synthetics";
|
@@ -16,6 +17,7 @@ const baseHeaders = {
|
|
16
17
|
Accept: "*/*",
|
17
18
|
};
|
18
19
|
export class UrlChecker {
|
20
|
+
requestOptions;
|
19
21
|
constructor(hostname, apiKey) {
|
20
22
|
const headers = { ...baseHeaders };
|
21
23
|
if (apiKey) {
|
@@ -150,8 +152,9 @@ function validateStatusCodeAndContentType(statusCode, contentType) {
|
|
150
152
|
}
|
151
153
|
// DEPRECATED
|
152
154
|
export class ResponseChecker {
|
155
|
+
contentType;
|
156
|
+
checkCors = true;
|
153
157
|
constructor(contentType) {
|
154
|
-
this.checkCors = true;
|
155
158
|
this.contentType = contentType;
|
156
159
|
}
|
157
160
|
static forJson() {
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { Construct } from "constructs";
|
2
|
+
import { CfnDocumentationPart, Resource } from "aws-cdk-lib/aws-apigateway";
|
2
3
|
// Documentation parts are objects that describe an API Gateway API or parts of an API
|
3
4
|
// https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-documenting-api.html
|
4
5
|
/**
|
@@ -63,6 +64,9 @@ export function addTagsAndSummary(methodDescription, tags, summary, resource, st
|
|
63
64
|
addDocumentation(methodDescription, { tags, summary }, resource, stack);
|
64
65
|
}
|
65
66
|
export class DocumentationPart {
|
67
|
+
parameterName;
|
68
|
+
type;
|
69
|
+
documentationProperties;
|
66
70
|
constructor(parameterName, documentationProperties, type) {
|
67
71
|
this.parameterName = parameterName;
|
68
72
|
this.documentationProperties = documentationProperties;
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { Vpc } from "aws-cdk-lib/aws-ec2";
|
2
|
-
import { CfnOutput, Fn } from "aws-cdk-lib";
|
2
|
+
import { CfnOutput, Fn, Stack } from "aws-cdk-lib";
|
3
|
+
import { Construct } from "constructs";
|
3
4
|
export class OldStackImports {
|
5
|
+
static AURORAINSTANCE_SG_IMPORT_NAME = "AuroraSG";
|
6
|
+
static RDSPROXY_SG_IMPORT_NAME = "RDSProxySG";
|
4
7
|
}
|
5
|
-
OldStackImports.AURORAINSTANCE_SG_IMPORT_NAME = "AuroraSG";
|
6
|
-
OldStackImports.RDSPROXY_SG_IMPORT_NAME = "RDSProxySG";
|
7
8
|
/**
|
8
9
|
* Import VPC from other stack outputs
|
9
10
|
*/
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { Rule, Schedule } from "aws-cdk-lib/aws-events";
|
2
2
|
import { Duration } from "aws-cdk-lib";
|
3
3
|
import { LambdaFunction } from "aws-cdk-lib/aws-events-targets";
|
4
|
+
import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
|
5
|
+
import { Construct } from "constructs";
|
4
6
|
export class Scheduler extends Rule {
|
5
7
|
constructor(stack, ruleName, schedule, lambda) {
|
6
8
|
super(stack, ruleName, { ruleName, schedule });
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Construct } from "constructs";
|
2
2
|
import { Rule } from "aws-cdk-lib/aws-events";
|
3
|
-
import { ITopic } from "aws-cdk-lib/aws-sns";
|
3
|
+
import type { ITopic } from "aws-cdk-lib/aws-sns";
|
4
4
|
/**
|
5
5
|
* Automatic rule for Security Hub. Send notification to given topic if the following conditions apply:
|
6
6
|
* * There is a finding with a status of NEW
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { RequestValidator, Resource, IModel } from "aws-cdk-lib/aws-apigateway";
|
1
|
+
import { RequestValidator, Resource, type IModel } from "aws-cdk-lib/aws-apigateway";
|
2
2
|
import { Queue } from "aws-cdk-lib/aws-sqs";
|
3
3
|
import { Construct } from "constructs";
|
4
4
|
export declare function attachQueueToApiGatewayResource(stack: Construct, queue: Queue, resource: Resource, requestValidator: RequestValidator, resourceName: string, apiKeyRequired: boolean, requestModels?: Record<string, IModel>): void;
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { Aws } from "aws-cdk-lib";
|
2
|
-
import { AwsIntegration, PassthroughBehavior } from "aws-cdk-lib/aws-apigateway";
|
2
|
+
import { AwsIntegration, PassthroughBehavior, RequestValidator, Resource } from "aws-cdk-lib/aws-apigateway";
|
3
|
+
import { Queue } from "aws-cdk-lib/aws-sqs";
|
3
4
|
import { PolicyStatement, Role, ServicePrincipal } from "aws-cdk-lib/aws-iam";
|
5
|
+
import { Construct } from "constructs";
|
4
6
|
export function attachQueueToApiGatewayResource(stack, queue, resource, requestValidator, resourceName, apiKeyRequired, requestModels) {
|
5
7
|
// role for API Gateway
|
6
8
|
const apiGwRole = new Role(stack, `${resourceName}APIGatewayToSQSRole`, {
|
@@ -7,8 +7,9 @@ import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
7
7
|
import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
|
8
8
|
import { ComparisonOperator, TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
|
9
9
|
import { SnsAction } from "aws-cdk-lib/aws-cloudwatch-actions";
|
10
|
-
import { S3 } from "@aws-sdk/client-s3";
|
10
|
+
import { S3, S3Client } from "@aws-sdk/client-s3";
|
11
11
|
import { Upload } from "@aws-sdk/lib-storage";
|
12
|
+
import { DigitrafficStack } from "./stack/stack.mjs";
|
12
13
|
import { MonitoredFunction } from "./stack/monitoredfunction.mjs";
|
13
14
|
/**
|
14
15
|
* Construct for creating SQS-queues.
|
@@ -1,15 +1,15 @@
|
|
1
|
-
import { Architecture, Code, FunctionProps, Runtime } from "aws-cdk-lib/aws-lambda";
|
2
|
-
import { IVpc, SubnetSelection } from "aws-cdk-lib/aws-ec2";
|
1
|
+
import { Architecture, Code, type FunctionProps, Runtime } from "aws-cdk-lib/aws-lambda";
|
2
|
+
import type { IVpc, SubnetSelection } from "aws-cdk-lib/aws-ec2";
|
3
3
|
import { Role } from "aws-cdk-lib/aws-iam";
|
4
4
|
import { DigitrafficStack } from "./stack.mjs";
|
5
|
-
import { MonitoredFunctionAlarmProps } from "./monitoredfunction.mjs";
|
5
|
+
import type { MonitoredFunctionAlarmProps } from "./monitoredfunction.mjs";
|
6
6
|
export type LambdaEnvironment = Record<string, string>;
|
7
7
|
export type DBLambdaEnvironment = LambdaEnvironment & {
|
8
8
|
SECRET_ID?: string;
|
9
9
|
DB_APPLICATION: string;
|
10
10
|
};
|
11
11
|
export declare function databaseFunctionProps(stack: DigitrafficStack, environment: LambdaEnvironment, lambdaName: string, simpleLambdaName: string, config?: Partial<FunctionParameters>): FunctionProps;
|
12
|
-
export declare function lambdaFunctionProps(
|
12
|
+
export declare function lambdaFunctionProps(_: DigitrafficStack, environment: LambdaEnvironment, lambdaName: string, simpleLambdaName: string, config?: Partial<FunctionParameters>): FunctionProps;
|
13
13
|
export declare function defaultLambdaConfiguration(config: FunctionParameters): FunctionProps;
|
14
14
|
export interface FunctionParameters {
|
15
15
|
memorySize?: number;
|
@@ -1,6 +1,8 @@
|
|
1
|
-
import { Architecture, AssetCode, Runtime, } from "aws-cdk-lib/aws-lambda";
|
1
|
+
import { Architecture, AssetCode, Code, Runtime, } from "aws-cdk-lib/aws-lambda";
|
2
2
|
import { Duration } from "aws-cdk-lib";
|
3
3
|
import { RetentionDays } from "aws-cdk-lib/aws-logs";
|
4
|
+
import { Role } from "aws-cdk-lib/aws-iam";
|
5
|
+
import { DigitrafficStack } from "./stack.mjs";
|
4
6
|
export function databaseFunctionProps(stack, environment, lambdaName, simpleLambdaName, config) {
|
5
7
|
const vpcSubnets = stack.vpc
|
6
8
|
? {
|
@@ -16,7 +18,7 @@ export function databaseFunctionProps(stack, environment, lambdaName, simpleLamb
|
|
16
18
|
},
|
17
19
|
};
|
18
20
|
}
|
19
|
-
export function lambdaFunctionProps(
|
21
|
+
export function lambdaFunctionProps(_, environment, lambdaName, simpleLambdaName, config) {
|
20
22
|
return {
|
21
23
|
runtime: config?.runtime ?? Runtime.NODEJS_20_X,
|
22
24
|
architecture: config?.architecture ?? Architecture.ARM_64,
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { Function, FunctionProps } from "aws-cdk-lib/aws-lambda";
|
1
|
+
import { Function, type FunctionProps } from "aws-cdk-lib/aws-lambda";
|
2
2
|
import { Stack } from "aws-cdk-lib";
|
3
3
|
import { ComparisonOperator } from "aws-cdk-lib/aws-cloudwatch";
|
4
4
|
import { DigitrafficStack } from "./stack.mjs";
|
5
|
-
import { ITopic } from "aws-cdk-lib/aws-sns";
|
6
|
-
import { LambdaEnvironment, MonitoredFunctionParameters } from "./lambda-configs.mjs";
|
5
|
+
import type { ITopic } from "aws-cdk-lib/aws-sns";
|
6
|
+
import { type LambdaEnvironment, type MonitoredFunctionParameters } from "./lambda-configs.mjs";
|
7
7
|
import { TrafficType } from "../../../types/traffictype.mjs";
|
8
8
|
/**
|
9
9
|
* Allows customization of CloudWatch Alarm properties
|
@@ -1,13 +1,32 @@
|
|
1
|
-
import { Function } from "aws-cdk-lib/aws-lambda";
|
1
|
+
import { Function, LoggingFormat } from "aws-cdk-lib/aws-lambda";
|
2
|
+
import { Stack } from "aws-cdk-lib";
|
2
3
|
import { SnsAction } from "aws-cdk-lib/aws-cloudwatch-actions";
|
3
|
-
import { ComparisonOperator } from "aws-cdk-lib/aws-cloudwatch";
|
4
|
+
import { ComparisonOperator, Metric } from "aws-cdk-lib/aws-cloudwatch";
|
5
|
+
import { DigitrafficStack } from "./stack.mjs";
|
4
6
|
import { databaseFunctionProps, } from "./lambda-configs.mjs";
|
5
7
|
import { DigitrafficLogSubscriptions } from "./subscription.mjs";
|
8
|
+
import { TrafficType } from "../../../types/traffictype.mjs";
|
6
9
|
import _ from "lodash";
|
7
10
|
/**
|
8
11
|
* Creates a Lambda function that monitors default CloudWatch Lambda metrics with CloudWatch Alarms.
|
9
12
|
*/
|
10
13
|
export class MonitoredFunction extends Function {
|
14
|
+
givenName;
|
15
|
+
/** disable all alarms */
|
16
|
+
static DISABLE_ALARMS = {
|
17
|
+
durationAlarmProps: {
|
18
|
+
create: false,
|
19
|
+
},
|
20
|
+
durationWarningProps: {
|
21
|
+
create: false,
|
22
|
+
},
|
23
|
+
errorAlarmProps: {
|
24
|
+
create: false,
|
25
|
+
},
|
26
|
+
throttleAlarmProps: {
|
27
|
+
create: false,
|
28
|
+
},
|
29
|
+
};
|
11
30
|
/**
|
12
31
|
* Create new MonitoredFunction. Use topics from given DigitrafficStack.
|
13
32
|
*
|
@@ -56,7 +75,8 @@ export class MonitoredFunction extends Function {
|
|
56
75
|
* @param props Monitored function properties
|
57
76
|
*/
|
58
77
|
constructor(scope, id, functionProps, alarmSnsTopic, warningSnsTopic, production, trafficType, props) {
|
59
|
-
|
78
|
+
// Set default loggingFormat to JSON if not explicitly set to TEXT
|
79
|
+
super(scope, id, { ...{ loggingFormat: LoggingFormat.JSON }, ...functionProps });
|
60
80
|
if (functionProps.functionName === undefined) {
|
61
81
|
throw new Error("Function name not provided");
|
62
82
|
}
|
@@ -98,21 +118,6 @@ export class MonitoredFunction extends Function {
|
|
98
118
|
return production ? alarmAction : warningAction;
|
99
119
|
}
|
100
120
|
}
|
101
|
-
/** disable all alarms */
|
102
|
-
MonitoredFunction.DISABLE_ALARMS = {
|
103
|
-
durationAlarmProps: {
|
104
|
-
create: false,
|
105
|
-
},
|
106
|
-
durationWarningProps: {
|
107
|
-
create: false,
|
108
|
-
},
|
109
|
-
errorAlarmProps: {
|
110
|
-
create: false,
|
111
|
-
},
|
112
|
-
throttleAlarmProps: {
|
113
|
-
create: false,
|
114
|
-
},
|
115
|
-
};
|
116
121
|
export class MonitoredDBFunction {
|
117
122
|
/**
|
118
123
|
* Create new MonitoredDBFunction. Use topics from given DigitrafficStack. Generate names from given name and configuration shortName.
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { IResource, JsonSchema, Resource, RestApi, RestApiProps } from "aws-cdk-lib/aws-apigateway";
|
1
|
+
import { type IResource, type JsonSchema, Resource, RestApi, type RestApiProps } from "aws-cdk-lib/aws-apigateway";
|
2
2
|
import { PolicyDocument } from "aws-cdk-lib/aws-iam";
|
3
3
|
import { Construct } from "constructs";
|
4
|
-
import { ModelWithReference } from "../../types/model-with-reference.mjs";
|
4
|
+
import type { ModelWithReference } from "../../types/model-with-reference.mjs";
|
5
5
|
import { DocumentationPart } from "../documentation.mjs";
|
6
6
|
import { DigitrafficStack } from "./stack.mjs";
|
7
7
|
export declare class DigitrafficRestApi extends RestApi {
|
@@ -1,10 +1,15 @@
|
|
1
|
-
import { CfnDocumentationPart, EndpointType, GatewayResponse, MethodLoggingLevel, MockIntegration, ResponseType, RestApi, } from "aws-cdk-lib/aws-apigateway";
|
1
|
+
import { CfnDocumentationPart, EndpointType, GatewayResponse, MethodLoggingLevel, MockIntegration, Model, Resource, ResponseType, RestApi, } from "aws-cdk-lib/aws-apigateway";
|
2
2
|
import { AnyPrincipal, Effect, PolicyDocument, PolicyStatement, } from "aws-cdk-lib/aws-iam";
|
3
|
+
import { Construct } from "constructs";
|
3
4
|
import { getModelReference } from "../../../utils/api-model.mjs";
|
4
5
|
import { MediaType } from "../../types/mediatypes.mjs";
|
6
|
+
import { DocumentationPart } from "../documentation.mjs";
|
5
7
|
import { createDefaultUsagePlan, createUsagePlan } from "../usage-plans.mjs";
|
8
|
+
import { DigitrafficStack } from "./stack.mjs";
|
6
9
|
import _ from "lodash";
|
7
10
|
export class DigitrafficRestApi extends RestApi {
|
11
|
+
apiKeyIds;
|
12
|
+
enableDocumentation;
|
8
13
|
constructor(stack, apiId, apiName, allowFromIpAddresses, config) {
|
9
14
|
const policyDocument = allowFromIpAddresses == null
|
10
15
|
? createDefaultPolicyDocument()
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { IAspect } from "aws-cdk-lib";
|
1
|
+
import { type IAspect } from "aws-cdk-lib";
|
2
2
|
import { DigitrafficStack } from "./stack.mjs";
|
3
|
-
import { IConstruct } from "constructs";
|
3
|
+
import type { IConstruct } from "constructs";
|
4
4
|
export declare class StackCheckingAspect implements IAspect {
|
5
5
|
private readonly stackShortName?;
|
6
6
|
private readonly whitelistedResources?;
|
@@ -24,6 +24,8 @@ var ResourceType;
|
|
24
24
|
ResourceType["logGroupRetention"] = "LOG_GROUP_RETENTION";
|
25
25
|
})(ResourceType || (ResourceType = {}));
|
26
26
|
export class StackCheckingAspect {
|
27
|
+
stackShortName;
|
28
|
+
whitelistedResources;
|
27
29
|
constructor(stackShortName, whitelistedResources) {
|
28
30
|
this.stackShortName = stackShortName;
|
29
31
|
this.whitelistedResources = whitelistedResources;
|
@@ -140,6 +142,9 @@ export class StackCheckingAspect {
|
|
140
142
|
const split = key.split(".");
|
141
143
|
const type = split[2];
|
142
144
|
const name = split[3];
|
145
|
+
if (name === undefined) {
|
146
|
+
throw Error('Name should not be undefined');
|
147
|
+
}
|
143
148
|
if (type === "querystring" && !StackCheckingAspect.isValidQueryString(name)) {
|
144
149
|
this.addAnnotation(node, name, "Querystring should be in snake_case");
|
145
150
|
}
|
@@ -157,7 +162,7 @@ export class StackCheckingAspect {
|
|
157
162
|
checkLogGroupRetention(node) {
|
158
163
|
if (node instanceof LogRetention) {
|
159
164
|
const child = node.node.defaultChild;
|
160
|
-
const retention = child
|
165
|
+
const retention = child?.['_cfnProperties']?.['RetentionInDays'];
|
161
166
|
if (!retention) {
|
162
167
|
this.addAnnotation(node, ResourceType.logGroupRetention, "Log group must define log group retention");
|
163
168
|
}
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import { Stack, StackProps } from "aws-cdk-lib";
|
2
|
-
import { type ISecurityGroup, IVpc } from "aws-cdk-lib/aws-ec2";
|
3
|
-
import { ITopic } from "aws-cdk-lib/aws-sns";
|
4
|
-
import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
1
|
+
import { Stack, type StackProps } from "aws-cdk-lib";
|
2
|
+
import { type ISecurityGroup, type IVpc } from "aws-cdk-lib/aws-ec2";
|
3
|
+
import { type ITopic } from "aws-cdk-lib/aws-sns";
|
4
|
+
import { type ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
5
5
|
import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
|
6
6
|
import { Construct } from "constructs";
|
7
7
|
import { TrafficType } from "../../../types/traffictype.mjs";
|
8
|
-
import { DBLambdaEnvironment } from "./lambda-configs.mjs";
|
8
|
+
import type { DBLambdaEnvironment } from "./lambda-configs.mjs";
|
9
9
|
export declare const SOLUTION_KEY = "Solution";
|
10
10
|
export declare const SSM_KEY_WARNING_TOPIC = "/digitraffic/monitoring/warning-topic";
|
11
11
|
export declare const SSM_KEY_ALARM_TOPIC = "/digitraffic/monitoring/alarm-topic";
|
@@ -3,13 +3,22 @@ import { SecurityGroup, Vpc } from "aws-cdk-lib/aws-ec2";
|
|
3
3
|
import { Topic } from "aws-cdk-lib/aws-sns";
|
4
4
|
import { StringParameter } from "aws-cdk-lib/aws-ssm";
|
5
5
|
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
|
6
|
+
import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
|
6
7
|
import { StackCheckingAspect } from "./stack-checking-aspect.mjs";
|
8
|
+
import { Construct } from "constructs";
|
9
|
+
import { TrafficType } from "../../../types/traffictype.mjs";
|
7
10
|
const SSM_ROOT = "/digitraffic";
|
8
11
|
export const SOLUTION_KEY = "Solution";
|
9
12
|
const MONITORING_ROOT = "/monitoring";
|
10
13
|
export const SSM_KEY_WARNING_TOPIC = `${SSM_ROOT}${MONITORING_ROOT}/warning-topic`;
|
11
14
|
export const SSM_KEY_ALARM_TOPIC = `${SSM_ROOT}${MONITORING_ROOT}/alarm-topic`;
|
12
15
|
export class DigitrafficStack extends Stack {
|
16
|
+
vpc;
|
17
|
+
lambdaDbSg;
|
18
|
+
alarmTopic;
|
19
|
+
warningTopic;
|
20
|
+
secret;
|
21
|
+
configuration;
|
13
22
|
constructor(scope, id, configuration) {
|
14
23
|
super(scope, id, configuration.stackProps);
|
15
24
|
this.configuration = configuration;
|