@digitraffic/common 2026.3.17-1 → 2026.3.26-1-beta
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/README.md +18 -1
- package/dist/__test__/asserter.d.ts +13 -0
- package/dist/__test__/asserter.js +39 -0
- package/dist/__test__/db-testutils.d.ts +3 -0
- package/dist/__test__/db-testutils.js +38 -0
- package/dist/__test__/dependencies.test.d.ts +1 -0
- package/dist/__test__/dependencies.test.js +21 -0
- package/dist/__test__/imports.test.d.ts +1 -0
- package/dist/__test__/imports.test.js +318 -0
- package/dist/__test__/infra/acl-builder.test.d.ts +1 -0
- package/dist/__test__/infra/acl-builder.test.js +72 -0
- package/dist/__test__/infra/api/handler-factory.test.d.ts +1 -0
- package/dist/__test__/infra/api/handler-factory.test.js +42 -0
- package/dist/__test__/infra/api/integration.test.d.ts +1 -0
- package/dist/__test__/infra/api/integration.test.js +162 -0
- package/dist/__test__/infra/api/response.test.d.ts +1 -0
- package/dist/__test__/infra/api/response.test.js +77 -0
- package/dist/__test__/infra/api/static-integration.test.d.ts +1 -0
- package/dist/__test__/infra/api/static-integration.test.js +35 -0
- package/dist/__test__/infra/documentation.test.d.ts +1 -0
- package/dist/__test__/infra/documentation.test.js +38 -0
- package/dist/__test__/infra/scheduler.test.d.ts +1 -0
- package/dist/__test__/infra/scheduler.test.js +23 -0
- package/dist/__test__/infra/security-rule.test.d.ts +1 -0
- package/dist/__test__/infra/security-rule.test.js +21 -0
- package/dist/__test__/infra/stack/rest-apis.test.d.ts +1 -0
- package/dist/__test__/infra/stack/rest-apis.test.js +47 -0
- package/dist/__test__/marine/id_utils.test.d.ts +1 -0
- package/dist/__test__/marine/id_utils.test.js +45 -0
- package/dist/__test__/mock-ky.d.ts +2 -0
- package/dist/__test__/mock-ky.js +15 -0
- package/dist/__test__/promise/promise.test.d.ts +1 -0
- package/dist/__test__/promise/promise.test.js +126 -0
- package/dist/__test__/runtime/dt-logger.test.d.ts +1 -0
- package/dist/__test__/runtime/dt-logger.test.js +193 -0
- package/dist/__test__/secrets/secret-holder.test.d.ts +1 -0
- package/dist/__test__/secrets/secret-holder.test.js +96 -0
- package/dist/__test__/secrets/secret.test.d.ts +1 -0
- package/dist/__test__/secrets/secret.test.js +57 -0
- package/dist/__test__/stack/dt-function.test.d.ts +1 -0
- package/dist/__test__/stack/dt-function.test.js +340 -0
- package/dist/__test__/stack/rest-apis.test.d.ts +1 -0
- package/dist/__test__/stack/rest-apis.test.js +45 -0
- package/dist/__test__/test/mock-ky.test.d.ts +1 -0
- package/dist/__test__/test/mock-ky.test.js +46 -0
- package/dist/__test__/testutils.d.ts +12 -0
- package/dist/__test__/testutils.js +32 -0
- package/dist/__test__/types/lambda-proxy-types.test.d.ts +8 -0
- package/dist/__test__/types/lambda-proxy-types.test.js +155 -0
- package/dist/__test__/types/lambda-response-builder.test.d.ts +1 -0
- package/dist/__test__/types/lambda-response-builder.test.js +81 -0
- package/dist/__test__/types/lambda-response.test.d.ts +9 -0
- package/dist/__test__/types/lambda-response.test.js +73 -0
- package/dist/__test__/utils/base64.test.d.ts +1 -0
- package/dist/__test__/utils/base64.test.js +38 -0
- package/dist/__test__/utils/date-utils.test.d.ts +1 -0
- package/dist/__test__/utils/date-utils.test.js +32 -0
- package/dist/__test__/utils/geometry.test.d.ts +1 -0
- package/dist/__test__/utils/geometry.test.js +25 -0
- package/dist/__test__/utils/lambda-proxy-event.test.d.ts +1 -0
- package/dist/__test__/utils/lambda-proxy-event.test.js +45 -0
- package/dist/__test__/utils/logging.test.d.ts +1 -0
- package/dist/__test__/utils/logging.test.js +75 -0
- package/dist/__test__/utils/stop-watch.test.d.ts +1 -0
- package/dist/__test__/utils/stop-watch.test.js +118 -0
- package/dist/__test__/utils/utils.test.d.ts +1 -0
- package/dist/__test__/utils/utils.test.js +48 -0
- package/dist/aws/infra/acl-builder.d.ts +53 -0
- package/dist/aws/infra/acl-builder.js +407 -0
- package/dist/aws/infra/api/handler-factory.d.ts +22 -0
- package/dist/aws/infra/api/handler-factory.js +68 -0
- package/dist/aws/infra/api/integration.d.ts +49 -0
- package/dist/aws/infra/api/integration.js +162 -0
- package/dist/aws/infra/api/response.d.ts +62 -0
- package/dist/aws/infra/api/response.js +132 -0
- package/dist/aws/infra/api/responses.d.ts +60 -0
- package/dist/aws/infra/api/responses.js +90 -0
- package/dist/aws/infra/api/static-integration.d.ts +16 -0
- package/dist/aws/infra/api/static-integration.js +76 -0
- package/dist/aws/infra/bucket-policy.d.ts +38 -0
- package/dist/aws/infra/bucket-policy.js +30 -0
- package/dist/aws/infra/canaries/canary-alarm.d.ts +6 -0
- package/dist/aws/infra/canaries/canary-alarm.js +20 -0
- package/dist/aws/infra/canaries/canary-keys.d.ts +3 -0
- package/dist/aws/infra/canaries/canary-keys.js +4 -0
- package/dist/aws/infra/canaries/canary-parameters.d.ts +19 -0
- package/dist/aws/infra/canaries/canary-parameters.js +2 -0
- package/dist/aws/infra/canaries/canary-role.d.ts +14 -0
- package/dist/aws/infra/canaries/canary-role.js +51 -0
- package/dist/aws/infra/canaries/canary.d.ts +8 -0
- package/dist/aws/infra/canaries/canary.js +26 -0
- package/dist/aws/infra/canaries/database-canary.d.ts +17 -0
- package/dist/aws/infra/canaries/database-canary.js +65 -0
- package/dist/aws/infra/canaries/database-checker.d.ts +33 -0
- package/dist/aws/infra/canaries/database-checker.js +119 -0
- package/dist/aws/infra/canaries/url-canary.d.ts +16 -0
- package/dist/aws/infra/canaries/url-canary.js +55 -0
- package/dist/aws/infra/canaries/url-checker.d.ts +45 -0
- package/dist/aws/infra/canaries/url-checker.js +256 -0
- package/dist/aws/infra/documentation.d.ts +56 -0
- package/dist/aws/infra/documentation.js +90 -0
- package/dist/aws/infra/import-util.d.ts +17 -0
- package/dist/aws/infra/import-util.js +41 -0
- package/dist/aws/infra/scheduler.d.ts +12 -0
- package/dist/aws/infra/scheduler.js +27 -0
- package/dist/aws/infra/security-rule.d.ts +12 -0
- package/dist/aws/infra/security-rule.js +35 -0
- package/dist/aws/infra/sqs-integration.d.ts +4 -0
- package/dist/aws/infra/sqs-integration.js +85 -0
- package/dist/aws/infra/sqs-queue.d.ts +19 -0
- package/dist/aws/infra/sqs-queue.js +145 -0
- package/dist/aws/infra/stack/dt-function-alarms.d.ts +29 -0
- package/dist/aws/infra/stack/dt-function-alarms.js +54 -0
- package/dist/aws/infra/stack/dt-function.d.ts +124 -0
- package/dist/aws/infra/stack/dt-function.js +315 -0
- package/dist/aws/infra/stack/lambda-configs.d.ts +44 -0
- package/dist/aws/infra/stack/lambda-configs.js +71 -0
- package/dist/aws/infra/stack/lambda-log-group.d.ts +15 -0
- package/dist/aws/infra/stack/lambda-log-group.js +24 -0
- package/dist/aws/infra/stack/monitoredfunction.d.ts +85 -0
- package/dist/aws/infra/stack/monitoredfunction.js +147 -0
- package/dist/aws/infra/stack/parameters.d.ts +40 -0
- package/dist/aws/infra/stack/parameters.js +50 -0
- package/dist/aws/infra/stack/rest-api.d.ts +74 -0
- package/dist/aws/infra/stack/rest-api.js +235 -0
- package/dist/aws/infra/stack/stack-checking-aspect.d.ts +20 -0
- package/dist/aws/infra/stack/stack-checking-aspect.js +183 -0
- package/dist/aws/infra/stack/stack.d.ts +56 -0
- package/dist/aws/infra/stack/stack.js +71 -0
- package/dist/aws/infra/stack/subscription.d.ts +17 -0
- package/dist/aws/infra/stack/subscription.js +37 -0
- package/dist/aws/infra/stacks/db-dns-stack.d.ts +13 -0
- package/dist/aws/infra/stacks/db-dns-stack.js +60 -0
- package/dist/aws/infra/stacks/db-proxy-stack.d.ts +24 -0
- package/dist/aws/infra/stacks/db-proxy-stack.js +74 -0
- package/dist/aws/infra/stacks/db-stack.d.ts +65 -0
- package/dist/aws/infra/stacks/db-stack.js +189 -0
- package/dist/aws/infra/stacks/intra-stack-configuration.d.ts +5 -0
- package/dist/aws/infra/stacks/intra-stack-configuration.js +2 -0
- package/dist/aws/infra/stacks/network-stack.d.ts +14 -0
- package/dist/aws/infra/stacks/network-stack.js +45 -0
- package/dist/aws/infra/usage-plans.d.ts +16 -0
- package/dist/aws/infra/usage-plans.js +38 -0
- package/dist/aws/runtime/apikey.d.ts +2 -0
- package/dist/aws/runtime/apikey.js +13 -0
- package/dist/aws/runtime/digitraffic-integration-response.d.ts +8 -0
- package/dist/aws/runtime/digitraffic-integration-response.js +25 -0
- package/dist/aws/runtime/dt-logger-default.d.ts +9 -0
- package/dist/aws/runtime/dt-logger-default.js +6 -0
- package/dist/aws/runtime/dt-logger.d.ts +117 -0
- package/dist/aws/runtime/dt-logger.js +159 -0
- package/dist/aws/runtime/environment.d.ts +5 -0
- package/dist/aws/runtime/environment.js +7 -0
- package/dist/aws/runtime/s3.d.ts +3 -0
- package/dist/aws/runtime/s3.js +21 -0
- package/dist/aws/runtime/secrets/dbsecret.d.ts +16 -0
- package/dist/aws/runtime/secrets/dbsecret.js +26 -0
- package/dist/aws/runtime/secrets/proxy-holder.d.ts +9 -0
- package/dist/aws/runtime/secrets/proxy-holder.js +25 -0
- package/dist/aws/runtime/secrets/rds-holder.d.ts +9 -0
- package/dist/aws/runtime/secrets/rds-holder.js +25 -0
- package/dist/aws/runtime/secrets/secret-holder.d.ts +30 -0
- package/dist/aws/runtime/secrets/secret-holder.js +81 -0
- package/dist/aws/runtime/secrets/secret.d.ts +8 -0
- package/dist/aws/runtime/secrets/secret.js +61 -0
- package/dist/aws/types/errors.d.ts +8 -0
- package/dist/aws/types/errors.js +13 -0
- package/dist/aws/types/lambda-proxy-types.d.ts +59 -0
- package/dist/aws/types/lambda-proxy-types.js +210 -0
- package/dist/aws/types/lambda-response.d.ts +89 -0
- package/dist/aws/types/lambda-response.js +204 -0
- package/dist/aws/types/mediatypes.d.ts +11 -0
- package/dist/aws/types/mediatypes.js +14 -0
- package/dist/aws/types/model-with-reference.d.ts +7 -0
- package/dist/aws/types/model-with-reference.js +2 -0
- package/dist/aws/types/tags.d.ts +2 -0
- package/dist/aws/types/tags.js +4 -0
- package/dist/database/database.d.ts +27 -0
- package/dist/database/database.js +95 -0
- package/dist/database/last-updated.d.ts +15 -0
- package/dist/database/last-updated.js +46 -0
- package/dist/database/models.d.ts +6 -0
- package/dist/database/models.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/marine/id_utils.d.ts +3 -0
- package/dist/marine/id_utils.js +36 -0
- package/dist/marine/rtz.d.ts +48 -0
- package/dist/marine/rtz.js +2 -0
- package/dist/types/async-timeout-error.d.ts +3 -0
- package/dist/types/async-timeout-error.js +6 -0
- package/dist/types/either.d.ts +9 -0
- package/dist/types/either.js +2 -0
- package/dist/types/geojson.d.ts +47 -0
- package/dist/types/geojson.js +51 -0
- package/dist/types/http-error.d.ts +4 -0
- package/dist/types/http-error.js +8 -0
- package/dist/types/input-error.d.ts +2 -0
- package/dist/types/input-error.js +3 -0
- package/dist/types/language.d.ts +5 -0
- package/dist/types/language.js +7 -0
- package/dist/types/nullable.d.ts +24 -0
- package/dist/types/nullable.js +2 -0
- package/dist/types/openapi-schema.d.ts +932 -0
- package/dist/types/openapi-schema.js +151 -0
- package/dist/types/traffictype.d.ts +11 -0
- package/dist/types/traffictype.js +13 -0
- package/dist/types/urn.d.ts +1 -0
- package/dist/types/urn.js +2 -0
- package/dist/types/util-types.d.ts +11 -0
- package/dist/types/util-types.js +2 -0
- package/dist/types/validator.d.ts +4 -0
- package/dist/types/validator.js +9 -0
- package/dist/utils/api-model.d.ts +51 -0
- package/dist/utils/api-model.js +118 -0
- package/dist/utils/base64.d.ts +34 -0
- package/dist/utils/base64.js +53 -0
- package/dist/utils/date-utils.d.ts +27 -0
- package/dist/utils/date-utils.js +45 -0
- package/dist/utils/geojson-types.d.ts +14 -0
- package/dist/utils/geojson-types.js +15 -0
- package/dist/utils/geometry.d.ts +44 -0
- package/dist/utils/geometry.js +154 -0
- package/dist/utils/lambda-proxy-event.d.ts +9 -0
- package/dist/utils/lambda-proxy-event.js +31 -0
- package/dist/utils/logging.d.ts +40 -0
- package/dist/utils/logging.js +88 -0
- package/dist/utils/retry.d.ts +33 -0
- package/dist/utils/retry.js +135 -0
- package/dist/utils/slack.d.ts +5 -0
- package/dist/utils/slack.js +24 -0
- package/dist/utils/stop-watch.d.ts +46 -0
- package/dist/utils/stop-watch.js +114 -0
- package/dist/utils/utils.d.ts +95 -0
- package/dist/utils/utils.js +178 -0
- package/dist/utils/zod-utils.d.ts +27 -0
- package/dist/utils/zod-utils.js +57 -0
- package/package.json +30 -28
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { IVpc, SubnetSelection } from "aws-cdk-lib/aws-ec2";
|
|
2
|
+
import type { Role } from "aws-cdk-lib/aws-iam";
|
|
3
|
+
import type { Code, FunctionProps } from "aws-cdk-lib/aws-lambda";
|
|
4
|
+
import { Architecture, Runtime } from "aws-cdk-lib/aws-lambda";
|
|
5
|
+
import type { ILogGroup } from "aws-cdk-lib/aws-logs";
|
|
6
|
+
import type { MonitoredFunctionAlarmProps } from "./monitoredfunction.js";
|
|
7
|
+
import type { DigitrafficStack } from "./stack.js";
|
|
8
|
+
export type LambdaEnvironment = Record<string, string>;
|
|
9
|
+
export type DBLambdaEnvironment = LambdaEnvironment & {
|
|
10
|
+
SECRET_ID?: string;
|
|
11
|
+
DB_APPLICATION: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated use dt-function.ts: FunctionBuilder
|
|
15
|
+
*/
|
|
16
|
+
export declare function databaseFunctionProps(stack: DigitrafficStack, environment: LambdaEnvironment, lambdaName: string, simpleLambdaName: string, logGroup: ILogGroup, config?: Partial<FunctionParameters>): FunctionProps;
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated use dt-function.ts: FunctionBuilder
|
|
19
|
+
*/
|
|
20
|
+
export declare function lambdaFunctionProps(_: DigitrafficStack, environment: LambdaEnvironment, lambdaName: string, simpleLambdaName: string, logGroup: ILogGroup, config?: Partial<FunctionParameters>): FunctionProps;
|
|
21
|
+
export declare function defaultLambdaConfiguration(config: FunctionParameters): FunctionProps;
|
|
22
|
+
export interface FunctionParameters {
|
|
23
|
+
memorySize?: number;
|
|
24
|
+
timeout?: number;
|
|
25
|
+
functionName?: string;
|
|
26
|
+
code: Code;
|
|
27
|
+
handler: string;
|
|
28
|
+
logGroup: ILogGroup;
|
|
29
|
+
readOnly?: boolean;
|
|
30
|
+
environment?: Record<string, string>;
|
|
31
|
+
reservedConcurrentExecutions?: number;
|
|
32
|
+
role?: Role;
|
|
33
|
+
vpc?: IVpc;
|
|
34
|
+
vpcSubnets?: SubnetSelection;
|
|
35
|
+
runtime?: Runtime;
|
|
36
|
+
architecture?: Architecture;
|
|
37
|
+
singleLambda?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export type MonitoredFunctionParameters = FunctionParameters & {
|
|
40
|
+
readonly durationAlarmProps?: MonitoredFunctionAlarmProps;
|
|
41
|
+
readonly durationWarningProps?: MonitoredFunctionAlarmProps;
|
|
42
|
+
readonly errorAlarmProps?: MonitoredFunctionAlarmProps;
|
|
43
|
+
readonly throttleAlarmProps?: MonitoredFunctionAlarmProps;
|
|
44
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Duration } from "aws-cdk-lib";
|
|
2
|
+
import { Architecture, AssetCode, Runtime } from "aws-cdk-lib/aws-lambda";
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated use dt-function.ts: FunctionBuilder
|
|
5
|
+
*/
|
|
6
|
+
export function databaseFunctionProps(stack, environment, lambdaName, simpleLambdaName, logGroup, config) {
|
|
7
|
+
const vpcSubnets = stack.vpc
|
|
8
|
+
? {
|
|
9
|
+
subnets: stack.vpc.privateSubnets,
|
|
10
|
+
}
|
|
11
|
+
: undefined;
|
|
12
|
+
return {
|
|
13
|
+
...lambdaFunctionProps(stack, environment, lambdaName, simpleLambdaName, logGroup, config),
|
|
14
|
+
...{
|
|
15
|
+
vpc: stack.vpc ?? undefined,
|
|
16
|
+
vpcSubnets,
|
|
17
|
+
securityGroup: stack.lambdaDbSg ?? undefined,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated use dt-function.ts: FunctionBuilder
|
|
23
|
+
*/
|
|
24
|
+
export function lambdaFunctionProps(_, environment, lambdaName, simpleLambdaName, logGroup, config) {
|
|
25
|
+
return {
|
|
26
|
+
runtime: config?.runtime ?? Runtime.NODEJS_24_X,
|
|
27
|
+
architecture: config?.architecture ?? Architecture.ARM_64,
|
|
28
|
+
memorySize: config?.memorySize ?? 128,
|
|
29
|
+
functionName: lambdaName,
|
|
30
|
+
role: config?.role,
|
|
31
|
+
timeout: Duration.seconds(config?.timeout ?? 60),
|
|
32
|
+
logGroup: logGroup,
|
|
33
|
+
reservedConcurrentExecutions: config?.reservedConcurrentExecutions ?? 2,
|
|
34
|
+
code: getAssetCode(simpleLambdaName, config?.singleLambda ?? false),
|
|
35
|
+
handler: `${simpleLambdaName}.handler`,
|
|
36
|
+
environment,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function getAssetCode(simpleLambdaName, isSingleLambda) {
|
|
40
|
+
const lambdaPath = isSingleLambda
|
|
41
|
+
? `dist/lambda/`
|
|
42
|
+
: `dist/lambda/${simpleLambdaName}`;
|
|
43
|
+
return new AssetCode(lambdaPath);
|
|
44
|
+
}
|
|
45
|
+
export function defaultLambdaConfiguration(config) {
|
|
46
|
+
const props = {
|
|
47
|
+
runtime: Runtime.NODEJS_24_X,
|
|
48
|
+
memorySize: config.memorySize ?? 128,
|
|
49
|
+
functionName: config.functionName,
|
|
50
|
+
handler: config.handler,
|
|
51
|
+
environment: config.environment ?? {},
|
|
52
|
+
logGroup: config.logGroup,
|
|
53
|
+
reservedConcurrentExecutions: config.reservedConcurrentExecutions,
|
|
54
|
+
code: config.code,
|
|
55
|
+
role: config.role,
|
|
56
|
+
timeout: Duration.seconds(config.timeout ?? 10),
|
|
57
|
+
};
|
|
58
|
+
if (config.vpc) {
|
|
59
|
+
return {
|
|
60
|
+
...props,
|
|
61
|
+
...{
|
|
62
|
+
vpc: config.vpc,
|
|
63
|
+
vpcSubnets: {
|
|
64
|
+
subnets: config.vpc.privateSubnets,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return props;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=lambda-configs.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Stack } from "aws-cdk-lib";
|
|
2
|
+
import { LogGroup, RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
3
|
+
import type { DigitrafficStackLike } from "./stack.js";
|
|
4
|
+
export interface CreateLambdaLogGroupParams {
|
|
5
|
+
functionName: string;
|
|
6
|
+
retention?: RetentionDays;
|
|
7
|
+
}
|
|
8
|
+
export interface CreateLambdaLogGroupParamsForStack extends CreateLambdaLogGroupParams {
|
|
9
|
+
stack: Stack;
|
|
10
|
+
shortName: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CreateLambdaLogGroupParamsForDigitrafficStack extends CreateLambdaLogGroupParams {
|
|
13
|
+
stack: Stack & DigitrafficStackLike;
|
|
14
|
+
}
|
|
15
|
+
export declare function createLambdaLogGroup(params: CreateLambdaLogGroupParamsForStack | CreateLambdaLogGroupParamsForDigitrafficStack): LogGroup;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LogGroup, RetentionDays } from "aws-cdk-lib/aws-logs";
|
|
2
|
+
function isCreateLambdaLogGroupParamsForDigitrafficStack(params) {
|
|
3
|
+
return !!("configuration" in params.stack && params.stack?.configuration?.shortName);
|
|
4
|
+
}
|
|
5
|
+
export function createLambdaLogGroup(params) {
|
|
6
|
+
const _createLambdaLogGroup = (stack, functionName, shortName, retention) => {
|
|
7
|
+
return new LogGroup(stack, `${functionName}-LogGroup`, {
|
|
8
|
+
logGroupName: `/${shortName}/lambda/${functionName}`,
|
|
9
|
+
retention,
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
const getShortName = (params) => {
|
|
13
|
+
if (isCreateLambdaLogGroupParamsForDigitrafficStack(params)) {
|
|
14
|
+
return params.stack.configuration.shortName;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return params.shortName;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const { functionName, retention = RetentionDays.ONE_YEAR } = params;
|
|
21
|
+
const shortName = getShortName(params);
|
|
22
|
+
return _createLambdaLogGroup(params.stack, functionName, shortName, retention);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=lambda-log-group.js.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Stack } from "aws-cdk-lib";
|
|
2
|
+
import { ComparisonOperator } from "aws-cdk-lib/aws-cloudwatch";
|
|
3
|
+
import type { FunctionProps } from "aws-cdk-lib/aws-lambda";
|
|
4
|
+
import { Function as LambdaFunction } from "aws-cdk-lib/aws-lambda";
|
|
5
|
+
import type { ITopic } from "aws-cdk-lib/aws-sns";
|
|
6
|
+
import type { TrafficType } from "../../../types/traffictype.js";
|
|
7
|
+
import type { LambdaEnvironment, MonitoredFunctionParameters } from "./lambda-configs.js";
|
|
8
|
+
import type { DigitrafficStack } from "./stack.js";
|
|
9
|
+
/**
|
|
10
|
+
* Allows customization of CloudWatch Alarm properties
|
|
11
|
+
*/
|
|
12
|
+
export interface MonitoredFunctionAlarmProps {
|
|
13
|
+
/**
|
|
14
|
+
* Setting this to false will not create a CloudWatch alarm
|
|
15
|
+
*/
|
|
16
|
+
readonly create: boolean;
|
|
17
|
+
readonly threshold?: number;
|
|
18
|
+
readonly evaluationPeriods?: number;
|
|
19
|
+
readonly datapointsToAlarm?: number;
|
|
20
|
+
readonly comparisonOperator?: ComparisonOperator;
|
|
21
|
+
}
|
|
22
|
+
export interface MonitoredFunctionProps {
|
|
23
|
+
readonly durationAlarmProps?: MonitoredFunctionAlarmProps;
|
|
24
|
+
readonly durationWarningProps?: MonitoredFunctionAlarmProps;
|
|
25
|
+
readonly errorAlarmProps?: MonitoredFunctionAlarmProps;
|
|
26
|
+
readonly throttleAlarmProps?: MonitoredFunctionAlarmProps;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a Lambda function that monitors default CloudWatch Lambda metrics with CloudWatch Alarms.
|
|
30
|
+
*/
|
|
31
|
+
export declare class MonitoredFunction extends LambdaFunction {
|
|
32
|
+
readonly givenName: string;
|
|
33
|
+
/** disable all alarms */
|
|
34
|
+
static readonly DISABLE_ALARMS: MonitoredFunctionProps;
|
|
35
|
+
/**
|
|
36
|
+
* @param scope Stack
|
|
37
|
+
* @param id Lambda construct Id
|
|
38
|
+
* @param functionProps Lambda function properties
|
|
39
|
+
* @param alarmSnsTopic SNS topic for alarms
|
|
40
|
+
* @param warningSnsTopic SNS topic for warnings
|
|
41
|
+
* @param production Is the stack a production stack, used for determining the alarm topic
|
|
42
|
+
* @param trafficType Traffic type, used for alarm names. Set to null if Lambda is not related to any traffic type.
|
|
43
|
+
* @param props Monitored function properties
|
|
44
|
+
*/
|
|
45
|
+
constructor(scope: Stack, id: string, functionProps: FunctionProps, alarmSnsTopic: ITopic, warningSnsTopic: ITopic, production: boolean, trafficType: TrafficType | null, props?: MonitoredFunctionProps);
|
|
46
|
+
/**
|
|
47
|
+
* Create new MonitoredFunction. Use topics from given DigitrafficStack.
|
|
48
|
+
*
|
|
49
|
+
* @param stack DigitrafficStack
|
|
50
|
+
* @param id Lambda construct Id
|
|
51
|
+
* @param functionProps Lambda function properties
|
|
52
|
+
* @param props Monitored function properties
|
|
53
|
+
*/
|
|
54
|
+
static create(stack: DigitrafficStack, id: string, functionProps: FunctionProps, props?: Partial<MonitoredFunctionProps>): MonitoredFunction;
|
|
55
|
+
/**
|
|
56
|
+
* Create new MonitoredFunction. Use topics from given DigitrafficStack. Generate names from given name and configuration shortName.
|
|
57
|
+
*
|
|
58
|
+
* For example, shortName FOO and given name update-things will create function FOO-UpdateThings and use code from lambda/update-things/update-things.ts method handler.
|
|
59
|
+
*
|
|
60
|
+
* @param stack DigitrafficStack
|
|
61
|
+
* @param name param-case name
|
|
62
|
+
* @param environment Lambda environment
|
|
63
|
+
* @param functionParameters Lambda function parameters
|
|
64
|
+
*/
|
|
65
|
+
static createV2(stack: DigitrafficStack, name: string, environment: LambdaEnvironment, functionParameters?: Partial<MonitoredFunctionParameters>): MonitoredFunction;
|
|
66
|
+
private createAlarm;
|
|
67
|
+
private getAlarmActionForEnv;
|
|
68
|
+
}
|
|
69
|
+
export declare const MonitoredDBFunction: {
|
|
70
|
+
/**
|
|
71
|
+
* Create new MonitoredDBFunction. Use topics from given DigitrafficStack. Generate names from given name and configuration shortName.
|
|
72
|
+
* Grant secret.
|
|
73
|
+
*
|
|
74
|
+
* For example, shortName FOO and given name update-things will create function FOO-UpdateThings and use code from lambda/update-things/update-things.ts method handler.
|
|
75
|
+
*
|
|
76
|
+
* If you don't need to pass any extra arguments to lambda-environment, you can leave environment out and this function will create the
|
|
77
|
+
* default Lambda Environment with SECRET_ID and DB_APPLICATION.
|
|
78
|
+
*
|
|
79
|
+
* @param stack DigitrafficStack
|
|
80
|
+
* @param name param-case name
|
|
81
|
+
* @param environment Lambda environment
|
|
82
|
+
* @param functionParameters Lambda function parameters
|
|
83
|
+
*/
|
|
84
|
+
create(stack: DigitrafficStack, name: string, environment?: LambdaEnvironment, functionParameters?: Partial<MonitoredFunctionParameters>): MonitoredFunction;
|
|
85
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { ComparisonOperator } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
+
import { SnsAction } from "aws-cdk-lib/aws-cloudwatch-actions";
|
|
3
|
+
import { ApplicationLogLevel, Function as LambdaFunction, LoggingFormat, SystemLogLevel, } from "aws-cdk-lib/aws-lambda";
|
|
4
|
+
import { camelCase, startCase } from "es-toolkit";
|
|
5
|
+
import { databaseFunctionProps } from "./lambda-configs.js";
|
|
6
|
+
import { createLambdaLogGroup } from "./lambda-log-group.js";
|
|
7
|
+
/**
|
|
8
|
+
* Creates a Lambda function that monitors default CloudWatch Lambda metrics with CloudWatch Alarms.
|
|
9
|
+
*/
|
|
10
|
+
export class MonitoredFunction extends LambdaFunction {
|
|
11
|
+
givenName;
|
|
12
|
+
/** disable all alarms */
|
|
13
|
+
static DISABLE_ALARMS = {
|
|
14
|
+
durationAlarmProps: {
|
|
15
|
+
create: false,
|
|
16
|
+
},
|
|
17
|
+
durationWarningProps: {
|
|
18
|
+
create: false,
|
|
19
|
+
},
|
|
20
|
+
errorAlarmProps: {
|
|
21
|
+
create: false,
|
|
22
|
+
},
|
|
23
|
+
throttleAlarmProps: {
|
|
24
|
+
create: false,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* @param scope Stack
|
|
29
|
+
* @param id Lambda construct Id
|
|
30
|
+
* @param functionProps Lambda function properties
|
|
31
|
+
* @param alarmSnsTopic SNS topic for alarms
|
|
32
|
+
* @param warningSnsTopic SNS topic for warnings
|
|
33
|
+
* @param production Is the stack a production stack, used for determining the alarm topic
|
|
34
|
+
* @param trafficType Traffic type, used for alarm names. Set to null if Lambda is not related to any traffic type.
|
|
35
|
+
* @param props Monitored function properties
|
|
36
|
+
*/
|
|
37
|
+
constructor(scope, id, functionProps, alarmSnsTopic, warningSnsTopic, production, trafficType, props) {
|
|
38
|
+
// Set default loggingFormat to JSON if not explicitly set to TEXT
|
|
39
|
+
super(scope, id, {
|
|
40
|
+
...{
|
|
41
|
+
loggingFormat: LoggingFormat.JSON,
|
|
42
|
+
applicationLogLevelV2: ApplicationLogLevel.DEBUG,
|
|
43
|
+
systemLogLevelV2: SystemLogLevel.INFO,
|
|
44
|
+
},
|
|
45
|
+
...functionProps,
|
|
46
|
+
});
|
|
47
|
+
if (functionProps.functionName === undefined) {
|
|
48
|
+
throw new Error("Function name not provided");
|
|
49
|
+
}
|
|
50
|
+
this.givenName = functionProps.functionName;
|
|
51
|
+
const alarmSnsAction = new SnsAction(alarmSnsTopic);
|
|
52
|
+
const warningSnsAction = new SnsAction(warningSnsTopic);
|
|
53
|
+
if (props?.durationAlarmProps?.create !== false) {
|
|
54
|
+
if (!functionProps.timeout) {
|
|
55
|
+
throw new Error("Timeout needs to be explicitly set");
|
|
56
|
+
}
|
|
57
|
+
this.createAlarm(scope, this.metricDuration().with({ statistic: "max" }), "Duration", "Duration alarm", `Duration has exceeded ${functionProps.timeout.toSeconds()} seconds`, trafficType, this.getAlarmActionForEnv(alarmSnsAction, warningSnsAction, production), functionProps.timeout.toMilliseconds(), 1, 1, ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD, props?.durationAlarmProps);
|
|
58
|
+
}
|
|
59
|
+
if (props?.durationWarningProps?.create !== false) {
|
|
60
|
+
if (!functionProps.timeout) {
|
|
61
|
+
throw new Error("Timeout needs to be explicitly set");
|
|
62
|
+
}
|
|
63
|
+
this.createAlarm(scope, this.metricDuration().with({ statistic: "max" }), "Duration-Warning", "Duration warning", `Duration is 85 % of max ${functionProps.timeout.toSeconds()} seconds`, trafficType, warningSnsAction, functionProps.timeout.toMilliseconds() * 0.85, 1, 1, ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD, props?.durationWarningProps);
|
|
64
|
+
}
|
|
65
|
+
if (props?.errorAlarmProps?.create !== false) {
|
|
66
|
+
this.createAlarm(scope, this.metricErrors(), "Errors", "Errors alarm", "Invocations did not succeed", trafficType, this.getAlarmActionForEnv(alarmSnsAction, warningSnsAction, production), 1, 1, 1, ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD, props?.errorAlarmProps);
|
|
67
|
+
}
|
|
68
|
+
if (props?.throttleAlarmProps?.create !== false) {
|
|
69
|
+
this.createAlarm(scope, this.metricThrottles(), "Throttles", "Throttles alarm", "Has throttled", trafficType, this.getAlarmActionForEnv(alarmSnsAction, warningSnsAction, production), 0, 1, 1, ComparisonOperator.GREATER_THAN_THRESHOLD, props?.throttleAlarmProps);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Create new MonitoredFunction. Use topics from given DigitrafficStack.
|
|
74
|
+
*
|
|
75
|
+
* @param stack DigitrafficStack
|
|
76
|
+
* @param id Lambda construct Id
|
|
77
|
+
* @param functionProps Lambda function properties
|
|
78
|
+
* @param props Monitored function properties
|
|
79
|
+
*/
|
|
80
|
+
static create(stack, id, functionProps, props) {
|
|
81
|
+
if (props === MonitoredFunction.DISABLE_ALARMS &&
|
|
82
|
+
stack.configuration.production) {
|
|
83
|
+
throw new Error(`Function ${functionProps.functionName ?? undefined} has DISABLE_ALARMS. Remove before installing to production or define your own properties!`);
|
|
84
|
+
}
|
|
85
|
+
return new MonitoredFunction(stack, id, functionProps, stack.alarmTopic, stack.warningTopic, stack.configuration.production, stack.configuration.trafficType, props);
|
|
86
|
+
}
|
|
87
|
+
// noinspection JSUnusedGlobalSymbols
|
|
88
|
+
/**
|
|
89
|
+
* Create new MonitoredFunction. Use topics from given DigitrafficStack. Generate names from given name and configuration shortName.
|
|
90
|
+
*
|
|
91
|
+
* For example, shortName FOO and given name update-things will create function FOO-UpdateThings and use code from lambda/update-things/update-things.ts method handler.
|
|
92
|
+
*
|
|
93
|
+
* @param stack DigitrafficStack
|
|
94
|
+
* @param name param-case name
|
|
95
|
+
* @param environment Lambda environment
|
|
96
|
+
* @param functionParameters Lambda function parameters
|
|
97
|
+
*/
|
|
98
|
+
static createV2(stack, name, environment, functionParameters) {
|
|
99
|
+
const functionName = functionParameters?.functionName ??
|
|
100
|
+
`${stack.configuration.shortName}-${startCase(camelCase(name)).replace(/\s/g, "")}`;
|
|
101
|
+
const logGroup = createLambdaLogGroup({ stack, functionName });
|
|
102
|
+
const functionProps = databaseFunctionProps(stack, environment, functionName, name, logGroup, functionParameters);
|
|
103
|
+
return MonitoredFunction.create(stack, functionName, functionProps, functionParameters);
|
|
104
|
+
}
|
|
105
|
+
createAlarm(stack, metric, alarmId, alarmName, alarmDescription, trafficType, alarmSnsAction, threshold, evaluationPeriods, datapointsToAlarm, comparisonOperator, alarmProps) {
|
|
106
|
+
metric
|
|
107
|
+
.createAlarm(stack, `${this.node.id}-${alarmId}`, {
|
|
108
|
+
alarmName: `${trafficType ?? ""} ${stack.stackName} ${this.functionName} ${alarmName}`.trim(),
|
|
109
|
+
alarmDescription,
|
|
110
|
+
threshold: alarmProps?.threshold ?? threshold,
|
|
111
|
+
evaluationPeriods: alarmProps?.evaluationPeriods ?? evaluationPeriods,
|
|
112
|
+
datapointsToAlarm: alarmProps?.datapointsToAlarm ?? datapointsToAlarm,
|
|
113
|
+
comparisonOperator: alarmProps?.comparisonOperator ?? comparisonOperator,
|
|
114
|
+
})
|
|
115
|
+
.addAlarmAction(alarmSnsAction);
|
|
116
|
+
}
|
|
117
|
+
getAlarmActionForEnv(alarmAction, warningAction, production) {
|
|
118
|
+
return production ? alarmAction : warningAction;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export const MonitoredDBFunction = {
|
|
122
|
+
/**
|
|
123
|
+
* Create new MonitoredDBFunction. Use topics from given DigitrafficStack. Generate names from given name and configuration shortName.
|
|
124
|
+
* Grant secret.
|
|
125
|
+
*
|
|
126
|
+
* For example, shortName FOO and given name update-things will create function FOO-UpdateThings and use code from lambda/update-things/update-things.ts method handler.
|
|
127
|
+
*
|
|
128
|
+
* If you don't need to pass any extra arguments to lambda-environment, you can leave environment out and this function will create the
|
|
129
|
+
* default Lambda Environment with SECRET_ID and DB_APPLICATION.
|
|
130
|
+
*
|
|
131
|
+
* @param stack DigitrafficStack
|
|
132
|
+
* @param name param-case name
|
|
133
|
+
* @param environment Lambda environment
|
|
134
|
+
* @param functionParameters Lambda function parameters
|
|
135
|
+
*/
|
|
136
|
+
create(stack, name, environment, functionParameters) {
|
|
137
|
+
const functionName = functionParameters?.functionName ??
|
|
138
|
+
`${stack.configuration.shortName}-${startCase(camelCase(name)).replace(/\s/g, "")}`;
|
|
139
|
+
const logGroup = createLambdaLogGroup({ stack, functionName });
|
|
140
|
+
const env = environment ? environment : stack.createLambdaEnvironment();
|
|
141
|
+
const functionProps = databaseFunctionProps(stack, env, functionName, name, logGroup, functionParameters);
|
|
142
|
+
const mf = MonitoredFunction.create(stack, functionName, functionProps, functionParameters);
|
|
143
|
+
stack.grantSecret(mf);
|
|
144
|
+
return mf;
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=monitoredfunction.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { StringParameter } from "aws-cdk-lib/aws-ssm";
|
|
2
|
+
import type { Construct } from "constructs";
|
|
3
|
+
declare const PARAMETERS: {
|
|
4
|
+
readonly "topic.alarm": {
|
|
5
|
+
readonly parameterName: "/digitraffic/monitoring/alarm-topic";
|
|
6
|
+
};
|
|
7
|
+
readonly "topic.warning": {
|
|
8
|
+
readonly parameterName: "/digitraffic/monitoring/warning-topic";
|
|
9
|
+
};
|
|
10
|
+
readonly "cluster.reader": {
|
|
11
|
+
readonly id: "ClusterReaderEndpointParameter";
|
|
12
|
+
readonly parameterName: "/digitraffic/db/reader-endpoint";
|
|
13
|
+
readonly description: "Cluster reader endpoint";
|
|
14
|
+
};
|
|
15
|
+
readonly "cluster.writer": {
|
|
16
|
+
readonly id: "ClusterWriterEndpointParameter";
|
|
17
|
+
readonly parameterName: "/digitraffic/db/writer-endpoint";
|
|
18
|
+
readonly description: "Cluster writer endpoint";
|
|
19
|
+
};
|
|
20
|
+
readonly "cluster.identifier": {
|
|
21
|
+
readonly id: "ClusterIdentifierParameter";
|
|
22
|
+
readonly parameterName: "/digitraffic/db/identifier";
|
|
23
|
+
readonly description: "Cluster identifier";
|
|
24
|
+
};
|
|
25
|
+
readonly "proxy.reader": {
|
|
26
|
+
readonly id: "ProxyReaderEndpointParameter";
|
|
27
|
+
readonly parameterName: "/digitraffic/db/proxy-reader-endpoint";
|
|
28
|
+
readonly description: "Proxy reader endpoint";
|
|
29
|
+
};
|
|
30
|
+
readonly "proxy.writer": {
|
|
31
|
+
readonly id: "ProxyWriterEndpointParameter";
|
|
32
|
+
readonly parameterName: "/digitraffic/db/proxy-writer-endpoint";
|
|
33
|
+
readonly description: "Proxy writer endpoint";
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export type ReadParameterType = keyof typeof PARAMETERS;
|
|
37
|
+
export type WriteParameterType = Exclude<Exclude<ReadParameterType, "topic.alarm">, "topic.warning">;
|
|
38
|
+
export declare function getParameterValue(scope: Construct, parameterType: ReadParameterType): string;
|
|
39
|
+
export declare function createParameter(scope: Construct, parameterType: WriteParameterType, stringValue: string): StringParameter;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { StringParameter } from "aws-cdk-lib/aws-ssm";
|
|
2
|
+
const SSM_ROOT = "/digitraffic";
|
|
3
|
+
const MONITORING_ROOT = "/monitoring";
|
|
4
|
+
const DB_ROOT = "/db";
|
|
5
|
+
const PARAMETERS = {
|
|
6
|
+
"topic.alarm": {
|
|
7
|
+
parameterName: `${SSM_ROOT}${MONITORING_ROOT}/alarm-topic`,
|
|
8
|
+
},
|
|
9
|
+
"topic.warning": {
|
|
10
|
+
parameterName: `${SSM_ROOT}${MONITORING_ROOT}/warning-topic`,
|
|
11
|
+
},
|
|
12
|
+
"cluster.reader": {
|
|
13
|
+
id: "ClusterReaderEndpointParameter",
|
|
14
|
+
parameterName: `${SSM_ROOT}${DB_ROOT}/reader-endpoint`,
|
|
15
|
+
description: "Cluster reader endpoint",
|
|
16
|
+
},
|
|
17
|
+
"cluster.writer": {
|
|
18
|
+
id: "ClusterWriterEndpointParameter",
|
|
19
|
+
parameterName: `${SSM_ROOT}${DB_ROOT}/writer-endpoint`,
|
|
20
|
+
description: "Cluster writer endpoint",
|
|
21
|
+
},
|
|
22
|
+
"cluster.identifier": {
|
|
23
|
+
id: "ClusterIdentifierParameter",
|
|
24
|
+
parameterName: `${SSM_ROOT}${DB_ROOT}/identifier`,
|
|
25
|
+
description: "Cluster identifier",
|
|
26
|
+
},
|
|
27
|
+
"proxy.reader": {
|
|
28
|
+
id: "ProxyReaderEndpointParameter",
|
|
29
|
+
parameterName: `${SSM_ROOT}${DB_ROOT}/proxy-reader-endpoint`,
|
|
30
|
+
description: "Proxy reader endpoint",
|
|
31
|
+
},
|
|
32
|
+
"proxy.writer": {
|
|
33
|
+
id: "ProxyWriterEndpointParameter",
|
|
34
|
+
parameterName: `${SSM_ROOT}${DB_ROOT}/proxy-writer-endpoint`,
|
|
35
|
+
description: "Proxy writer endpoint",
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
export function getParameterValue(scope, parameterType) {
|
|
39
|
+
const parameterName = PARAMETERS[parameterType].parameterName;
|
|
40
|
+
return StringParameter.valueForStringParameter(scope, parameterName);
|
|
41
|
+
}
|
|
42
|
+
export function createParameter(scope, parameterType, stringValue) {
|
|
43
|
+
const { id, parameterName, description } = PARAMETERS[parameterType];
|
|
44
|
+
return new StringParameter(scope, id, {
|
|
45
|
+
parameterName,
|
|
46
|
+
description,
|
|
47
|
+
stringValue,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=parameters.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Stack } from "aws-cdk-lib";
|
|
2
|
+
import type { IResource, JsonSchema, Resource, ResourceOptions, RestApiProps } from "aws-cdk-lib/aws-apigateway";
|
|
3
|
+
import { RestApi } from "aws-cdk-lib/aws-apigateway";
|
|
4
|
+
import { PolicyDocument } from "aws-cdk-lib/aws-iam";
|
|
5
|
+
import { StringParameter } from "aws-cdk-lib/aws-ssm";
|
|
6
|
+
import type { Construct } from "constructs";
|
|
7
|
+
import type { ModelWithReference } from "../../types/model-with-reference.js";
|
|
8
|
+
import type { DocumentationPart } from "../documentation.js";
|
|
9
|
+
import type { DigitrafficStackLike } from "./stack.js";
|
|
10
|
+
export declare const PUBLIC_REST_API_CORS_CONFIG: {
|
|
11
|
+
readonly defaultCorsPreflightOptions: {
|
|
12
|
+
readonly allowOrigins: string[];
|
|
13
|
+
readonly allowHeaders: ["Content-Type", "X-Amz-Date", "Authorization", "X-Api-Key", "X-Amz-Security-Token", "Digitraffic-User"];
|
|
14
|
+
readonly allowMethods: ["OPTIONS", "GET", "HEAD"];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export interface ExportParams {
|
|
18
|
+
/** Set apiKeyId when needed */
|
|
19
|
+
readonly apiKeyId?: string;
|
|
20
|
+
/** Override exportName, default is stack shortname */
|
|
21
|
+
readonly exportName?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class DigitrafficRestApi extends RestApi {
|
|
24
|
+
readonly apiKeyIds: string[];
|
|
25
|
+
readonly enableDocumentation: boolean;
|
|
26
|
+
private readonly _stack;
|
|
27
|
+
constructor(stack: Stack & DigitrafficStackLike, apiId: string, apiName: string, allowFromIpAddresses?: string[] | undefined, config?: Partial<RestApiProps>);
|
|
28
|
+
hostname(): string;
|
|
29
|
+
/** Export end point and api key to Parameter store */
|
|
30
|
+
exportEndpoint(): [StringParameter, StringParameter];
|
|
31
|
+
/** Export end point and given api key to Parameter store */
|
|
32
|
+
exportEndpoint(params: ExportParams): [StringParameter, StringParameter];
|
|
33
|
+
/**
|
|
34
|
+
* @param apiKeyId
|
|
35
|
+
* @param apiKeyName
|
|
36
|
+
* @deprecated Uses deprecated createUsagePlan that creates randomized API key names, use createUsagePlanV2 instead
|
|
37
|
+
*/
|
|
38
|
+
createUsagePlan(apiKeyId: string, apiKeyName: string): string;
|
|
39
|
+
createUsagePlanV2(apiName: string, apiKey?: string): string;
|
|
40
|
+
addJsonModel(modelName: string, schema: JsonSchema): ModelWithReference;
|
|
41
|
+
addCSVModel(modelName: string): ModelWithReference;
|
|
42
|
+
private getModelWithReference;
|
|
43
|
+
private addDocumentationPart;
|
|
44
|
+
documentResource(resource: Resource, ...documentationPart: DocumentationPart[]): void;
|
|
45
|
+
addResourceWithCorsOptionsSubTree(resource: Resource, pathPart: string, config?: ResourceOptions): Resource;
|
|
46
|
+
/**
|
|
47
|
+
* Add support for HTTP OPTIONS to an API GW resource,
|
|
48
|
+
* this is required for preflight CORS requests made by browsers.
|
|
49
|
+
* @param apiResource
|
|
50
|
+
*/
|
|
51
|
+
addCorsOptions(apiResource: IResource): void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Due to AWS API design API Gateway will always return 403 'Missing Authentication Token' for requests
|
|
55
|
+
* with a non-existent endpoint. This function translates this response to a 404.
|
|
56
|
+
* Requests with an invalid or missing API key are not affected (still return 403 'Forbidden').
|
|
57
|
+
* @param restApi RestApi
|
|
58
|
+
* @param stack Construct
|
|
59
|
+
*/
|
|
60
|
+
export declare function add404Support(restApi: RestApi, stack: Construct): void;
|
|
61
|
+
export declare function add401Support(restApi: RestApi, stack: Construct): void;
|
|
62
|
+
/**
|
|
63
|
+
* Due to AWS API design API Gateway will always return 403 'Missing Authentication Token' for requests
|
|
64
|
+
* with a non-existent endpoint. This function converts this response to a custom one.
|
|
65
|
+
* Requests with an invalid or missing API key are not affected (still return 403 'Forbidden').
|
|
66
|
+
* @param returnCode
|
|
67
|
+
* @param message
|
|
68
|
+
* @param restApi RestApi
|
|
69
|
+
* @param stack Construct
|
|
70
|
+
*/
|
|
71
|
+
export declare function setReturnCodeForMissingAuthenticationToken(returnCode: number, message: string, restApi: RestApi, stack: Construct): void;
|
|
72
|
+
export declare function createRestApi(stack: Construct, apiId: string, apiName: string, allowFromIpAddresses?: string[] | undefined): RestApi;
|
|
73
|
+
export declare function createDefaultPolicyDocument(): PolicyDocument;
|
|
74
|
+
export declare function createIpRestrictionPolicyDocument(allowFromIpAddresses: string[]): PolicyDocument;
|