@digitraffic/common 2024.1.10-1 → 2024.1.19-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.
Files changed (166) hide show
  1. package/dist/aws/infra/api/handler-factory.d.ts +2 -2
  2. package/dist/aws/infra/api/handler-factory.js +4 -9
  3. package/dist/aws/infra/api/integration.d.ts +1 -1
  4. package/dist/aws/infra/api/integration.js +9 -13
  5. package/dist/aws/infra/api/response.d.ts +2 -3
  6. package/dist/aws/infra/api/response.js +25 -30
  7. package/dist/aws/infra/api/responses.d.ts +2 -3
  8. package/dist/aws/infra/api/responses.js +25 -31
  9. package/dist/aws/infra/api/static-integration.d.ts +1 -1
  10. package/dist/aws/infra/api/static-integration.js +7 -11
  11. package/dist/aws/infra/canaries/canary-alarm.d.ts +1 -1
  12. package/dist/aws/infra/canaries/canary-alarm.js +7 -11
  13. package/dist/aws/infra/canaries/canary-keys.js +3 -6
  14. package/dist/aws/infra/canaries/canary-parameters.js +1 -2
  15. package/dist/aws/infra/canaries/canary-role.js +8 -12
  16. package/dist/aws/infra/canaries/canary.d.ts +2 -2
  17. package/dist/aws/infra/canaries/canary.js +9 -13
  18. package/dist/aws/infra/canaries/database-canary.d.ts +3 -3
  19. package/dist/aws/infra/canaries/database-canary.js +8 -12
  20. package/dist/aws/infra/canaries/database-checker.d.ts +1 -1
  21. package/dist/aws/infra/canaries/database-checker.js +10 -14
  22. package/dist/aws/infra/canaries/url-canary.d.ts +4 -4
  23. package/dist/aws/infra/canaries/url-canary.js +8 -12
  24. package/dist/aws/infra/canaries/url-checker.d.ts +2 -2
  25. package/dist/aws/infra/canaries/url-checker.js +33 -40
  26. package/dist/aws/infra/documentation.js +8 -16
  27. package/dist/aws/infra/import-util.js +10 -18
  28. package/dist/aws/infra/scheduler.js +10 -14
  29. package/dist/aws/infra/security-rule.js +4 -8
  30. package/dist/aws/infra/sqs-integration.d.ts +1 -2
  31. package/dist/aws/infra/sqs-integration.js +11 -15
  32. package/dist/aws/infra/sqs-queue.d.ts +1 -1
  33. package/dist/aws/infra/sqs-queue.js +30 -35
  34. package/dist/aws/infra/stack/lambda-configs.d.ts +2 -2
  35. package/dist/aws/infra/stack/lambda-configs.js +14 -20
  36. package/dist/aws/infra/stack/monitoredfunction.d.ts +3 -3
  37. package/dist/aws/infra/stack/monitoredfunction.js +19 -27
  38. package/dist/aws/infra/stack/parameters.d.ts +1 -1
  39. package/dist/aws/infra/stack/parameters.js +5 -10
  40. package/dist/aws/infra/stack/rest_apis.d.ts +3 -3
  41. package/dist/aws/infra/stack/rest_apis.js +41 -54
  42. package/dist/aws/infra/stack/stack-checking-aspect.d.ts +1 -1
  43. package/dist/aws/infra/stack/stack-checking-aspect.js +24 -31
  44. package/dist/aws/infra/stack/stack.d.ts +3 -4
  45. package/dist/aws/infra/stack/stack.js +16 -20
  46. package/dist/aws/infra/stack/subscription.d.ts +2 -2
  47. package/dist/aws/infra/stack/subscription.js +5 -10
  48. package/dist/aws/infra/stacks/db-dns-stack.d.ts +2 -2
  49. package/dist/aws/infra/stacks/db-dns-stack.js +25 -29
  50. package/dist/aws/infra/stacks/db-proxy-stack.d.ts +2 -2
  51. package/dist/aws/infra/stacks/db-proxy-stack.js +23 -27
  52. package/dist/aws/infra/stacks/db-stack.d.ts +3 -4
  53. package/dist/aws/infra/stacks/db-stack.js +30 -34
  54. package/dist/aws/infra/stacks/intra-stack-configuration.js +1 -2
  55. package/dist/aws/infra/stacks/network-stack.d.ts +2 -2
  56. package/dist/aws/infra/stacks/network-stack.js +14 -18
  57. package/dist/aws/infra/usage-plans.js +2 -7
  58. package/dist/aws/runtime/apikey.js +3 -7
  59. package/dist/aws/runtime/digitraffic-integration-response.d.ts +1 -1
  60. package/dist/aws/runtime/digitraffic-integration-response.js +7 -11
  61. package/dist/aws/runtime/dt-logger-default.d.ts +2 -2
  62. package/dist/aws/runtime/dt-logger-default.js +2 -5
  63. package/dist/aws/runtime/dt-logger.d.ts +1 -1
  64. package/dist/aws/runtime/dt-logger.js +3 -10
  65. package/dist/aws/runtime/environment.js +3 -7
  66. package/dist/aws/runtime/messaging.js +1 -5
  67. package/dist/aws/runtime/s3.js +3 -7
  68. package/dist/aws/runtime/secrets/dbsecret.d.ts +1 -1
  69. package/dist/aws/runtime/secrets/dbsecret.js +5 -9
  70. package/dist/aws/runtime/secrets/proxy-holder.js +12 -16
  71. package/dist/aws/runtime/secrets/rds-holder.js +12 -16
  72. package/dist/aws/runtime/secrets/secret-holder.d.ts +1 -1
  73. package/dist/aws/runtime/secrets/secret-holder.js +9 -13
  74. package/dist/aws/runtime/secrets/secret.js +7 -11
  75. package/dist/aws/types/errors.js +5 -9
  76. package/dist/aws/types/lambda-response.js +3 -10
  77. package/dist/aws/types/mediatypes.js +2 -5
  78. package/dist/aws/types/model-with-reference.js +1 -2
  79. package/dist/aws/types/proxytypes.js +1 -2
  80. package/dist/aws/types/tags.js +2 -5
  81. package/dist/database/cached.d.ts +1 -1
  82. package/dist/database/cached.js +8 -14
  83. package/dist/database/database.js +14 -21
  84. package/dist/database/last-updated.d.ts +1 -1
  85. package/dist/database/last-updated.js +8 -17
  86. package/dist/database/models.js +1 -2
  87. package/dist/index.d.ts +1 -0
  88. package/dist/index.js +2 -0
  89. package/dist/marine/id_utils.js +3 -9
  90. package/dist/marine/rtz.js +1 -2
  91. package/dist/test/asserter.js +1 -5
  92. package/dist/test/db-testutils.d.ts +1 -1
  93. package/dist/test/db-testutils.js +8 -13
  94. package/dist/test/httpserver.js +10 -14
  95. package/dist/test/secrets-manager.js +9 -35
  96. package/dist/test/testutils.js +8 -19
  97. package/dist/types/async-timeout-error.js +1 -5
  98. package/dist/types/aws-env.js +1 -2
  99. package/dist/types/either.js +1 -2
  100. package/dist/types/http-error.js +1 -5
  101. package/dist/types/input-error.js +1 -5
  102. package/dist/types/language.js +2 -5
  103. package/dist/types/nullable.d.ts +1 -1
  104. package/dist/types/nullable.js +1 -2
  105. package/dist/types/traffictype.js +2 -5
  106. package/dist/types/urn.js +1 -2
  107. package/dist/types/util-types.js +1 -2
  108. package/dist/types/validator.js +4 -9
  109. package/dist/utils/api-model.d.ts +1 -1
  110. package/dist/utils/api-model.js +17 -27
  111. package/dist/utils/base64.d.ts +1 -1
  112. package/dist/utils/base64.js +2 -7
  113. package/dist/utils/date-utils.js +9 -16
  114. package/dist/utils/geojson-types.js +2 -7
  115. package/dist/utils/geometry.js +15 -48
  116. package/dist/utils/logging.d.ts +1 -1
  117. package/dist/utils/logging.js +8 -13
  118. package/dist/utils/retry.js +21 -26
  119. package/dist/utils/slack.js +7 -14
  120. package/dist/utils/utils.d.ts +2 -2
  121. package/dist/utils/utils.js +14 -29
  122. package/package.json +107 -18
  123. package/src/aws/infra/api/handler-factory.ts +3 -3
  124. package/src/aws/infra/api/integration.ts +2 -2
  125. package/src/aws/infra/api/response.ts +3 -3
  126. package/src/aws/infra/api/responses.ts +4 -4
  127. package/src/aws/infra/api/static-integration.ts +2 -2
  128. package/src/aws/infra/canaries/canary-alarm.ts +1 -1
  129. package/src/aws/infra/canaries/canary.ts +3 -3
  130. package/src/aws/infra/canaries/database-canary.ts +3 -3
  131. package/src/aws/infra/canaries/database-checker.ts +6 -6
  132. package/src/aws/infra/canaries/url-canary.ts +6 -6
  133. package/src/aws/infra/canaries/url-checker.ts +8 -8
  134. package/src/aws/infra/sqs-integration.ts +1 -1
  135. package/src/aws/infra/sqs-queue.ts +2 -2
  136. package/src/aws/infra/stack/lambda-configs.ts +2 -2
  137. package/src/aws/infra/stack/monitoredfunction.ts +4 -4
  138. package/src/aws/infra/stack/parameters.ts +1 -1
  139. package/src/aws/infra/stack/rest_apis.ts +6 -6
  140. package/src/aws/infra/stack/stack-checking-aspect.ts +1 -1
  141. package/src/aws/infra/stack/stack.ts +4 -5
  142. package/src/aws/infra/stack/subscription.ts +2 -2
  143. package/src/aws/infra/stacks/db-dns-stack.ts +4 -4
  144. package/src/aws/infra/stacks/db-proxy-stack.ts +5 -5
  145. package/src/aws/infra/stacks/db-stack.ts +5 -5
  146. package/src/aws/infra/stacks/network-stack.ts +3 -3
  147. package/src/aws/runtime/digitraffic-integration-response.ts +2 -2
  148. package/src/aws/runtime/dt-logger-default.ts +2 -2
  149. package/src/aws/runtime/secrets/dbsecret.ts +1 -1
  150. package/src/aws/runtime/secrets/proxy-holder.ts +4 -4
  151. package/src/aws/runtime/secrets/rds-holder.ts +4 -4
  152. package/src/aws/runtime/secrets/secret-holder.ts +4 -4
  153. package/src/aws/runtime/secrets/secret.ts +2 -2
  154. package/src/database/cached.ts +1 -1
  155. package/src/database/database.ts +3 -3
  156. package/src/database/last-updated.ts +1 -1
  157. package/src/index.ts +2 -0
  158. package/src/test/db-testutils.ts +2 -2
  159. package/src/test/secrets-manager.ts +2 -2
  160. package/src/types/nullable.ts +1 -1
  161. package/src/utils/api-model.ts +1 -1
  162. package/src/utils/geometry.ts +5 -3
  163. package/src/utils/logging.ts +2 -2
  164. package/src/utils/retry.ts +3 -3
  165. package/src/utils/slack.ts +2 -2
  166. package/src/utils/utils.ts +3 -3
@@ -1,20 +1,14 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.StackCheckingAspect = void 0;
7
- const aws_cdk_lib_1 = require("aws-cdk-lib");
8
- const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
9
- const aws_s3_1 = require("aws-cdk-lib/aws-s3");
10
- const stack_1 = require("./stack");
11
- const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
12
- const aws_sqs_1 = require("aws-cdk-lib/aws-sqs");
13
- const aws_logs_1 = require("aws-cdk-lib/aws-logs");
14
- const change_case_1 = require("change-case");
15
- const lodash_1 = __importDefault(require("lodash"));
1
+ import { Annotations, Stack } from "aws-cdk-lib";
2
+ import { CfnFunction, Runtime } from "aws-cdk-lib/aws-lambda";
3
+ import { CfnBucket } from "aws-cdk-lib/aws-s3";
4
+ import { DigitrafficStack, SOLUTION_KEY } from "./stack.js";
5
+ import { CfnMethod, CfnResource } from "aws-cdk-lib/aws-apigateway";
6
+ import { CfnQueue } from "aws-cdk-lib/aws-sqs";
7
+ import { LogRetention } from "aws-cdk-lib/aws-logs";
8
+ import { kebabCase } from "change-case";
9
+ import _ from "lodash";
16
10
  const MAX_CONCURRENCY_LIMIT = 100;
17
- const NODE_RUNTIMES = [aws_lambda_1.Runtime.NODEJS_20_X.name, aws_lambda_1.Runtime.NODEJS_18_X.name];
11
+ const NODE_RUNTIMES = [Runtime.NODEJS_20_X.name, Runtime.NODEJS_18_X.name];
18
12
  var ResourceType;
19
13
  (function (ResourceType) {
20
14
  ResourceType["stackName"] = "STACK_NAME";
@@ -29,7 +23,7 @@ var ResourceType;
29
23
  ResourceType["queueEncryption"] = "QUEUE_ENCRYPTION";
30
24
  ResourceType["logGroupRetention"] = "LOG_GROUP_RETENTION";
31
25
  })(ResourceType || (ResourceType = {}));
32
- class StackCheckingAspect {
26
+ export class StackCheckingAspect {
33
27
  constructor(stackShortName, whitelistedResources) {
34
28
  this.stackShortName = stackShortName;
35
29
  this.whitelistedResources = whitelistedResources;
@@ -59,14 +53,14 @@ class StackCheckingAspect {
59
53
  // error && whitelisted -> warning
60
54
  // warning && whitelisted -> nothing
61
55
  if (isError && !isWhiteListed) {
62
- aws_cdk_lib_1.Annotations.of(node).addError(annotationMessage);
56
+ Annotations.of(node).addError(annotationMessage);
63
57
  }
64
58
  else if ((!isError && !isWhiteListed) || (isError && isWhiteListed)) {
65
- aws_cdk_lib_1.Annotations.of(node).addWarning(annotationMessage);
59
+ Annotations.of(node).addWarning(annotationMessage);
66
60
  }
67
61
  }
68
62
  checkStack(node) {
69
- if (node instanceof stack_1.DigitrafficStack) {
63
+ if (node instanceof DigitrafficStack) {
70
64
  if ((node.stackName.includes("Test") || node.stackName.includes("Tst")) &&
71
65
  node.configuration.production) {
72
66
  this.addAnnotation(node, ResourceType.stackName, "Production is set for Test-stack");
@@ -78,7 +72,7 @@ class StackCheckingAspect {
78
72
  }
79
73
  }
80
74
  checkFunction(node) {
81
- if (node instanceof aws_lambda_1.CfnFunction) {
75
+ if (node instanceof CfnFunction) {
82
76
  if (!node.reservedConcurrentExecutions) {
83
77
  this.addAnnotation(node, ResourceType.reservedConcurrentConcurrency, "Function must have reservedConcurrentConcurrency");
84
78
  }
@@ -102,14 +96,14 @@ class StackCheckingAspect {
102
96
  }
103
97
  }
104
98
  checkTags(node) {
105
- if (node instanceof aws_cdk_lib_1.Stack) {
106
- if (!node.tags.tagValues()[stack_1.SOLUTION_KEY]) {
99
+ if (node instanceof Stack) {
100
+ if (!node.tags.tagValues()[SOLUTION_KEY]) {
107
101
  this.addAnnotation(node, ResourceType.tagSolution, "Solution tag is missing");
108
102
  }
109
103
  }
110
104
  }
111
105
  checkBucket(node) {
112
- if (node instanceof aws_s3_1.CfnBucket) {
106
+ if (node instanceof CfnBucket) {
113
107
  const c = node.publicAccessBlockConfiguration;
114
108
  if (c &&
115
109
  (!c.blockPublicAcls ||
@@ -128,18 +122,18 @@ class StackCheckingAspect {
128
122
  if (path.includes("{")) {
129
123
  return this.isValidPath(path.split("{")[0]);
130
124
  }
131
- return (0, change_case_1.kebabCase)(path) === path;
125
+ return kebabCase(path) === path;
132
126
  }
133
127
  static isValidQueryString(name) {
134
- return lodash_1.default.snakeCase(name) === name;
128
+ return _.snakeCase(name) === name;
135
129
  }
136
130
  checkResourceCasing(node) {
137
- if (node instanceof aws_apigateway_1.CfnResource) {
131
+ if (node instanceof CfnResource) {
138
132
  if (!StackCheckingAspect.isValidPath(node.pathPart)) {
139
133
  this.addAnnotation(node, ResourceType.resourcePath, "Path part should be in kebab-case");
140
134
  }
141
135
  }
142
- else if (node instanceof aws_apigateway_1.CfnMethod) {
136
+ else if (node instanceof CfnMethod) {
143
137
  const integration = node.integration;
144
138
  if (integration?.requestParameters) {
145
139
  Object.keys(integration.requestParameters).forEach((key) => {
@@ -154,14 +148,14 @@ class StackCheckingAspect {
154
148
  }
155
149
  }
156
150
  checkQueueEncryption(node) {
157
- if (node instanceof aws_sqs_1.CfnQueue) {
151
+ if (node instanceof CfnQueue) {
158
152
  if (!node.kmsMasterKeyId) {
159
153
  this.addAnnotation(node, ResourceType.queueEncryption, "Queue must have encryption enabled");
160
154
  }
161
155
  }
162
156
  }
163
157
  checkLogGroupRetention(node) {
164
- if (node instanceof aws_logs_1.LogRetention) {
158
+ if (node instanceof LogRetention) {
165
159
  const child = node.node.defaultChild;
166
160
  const retention = child._cfnProperties.RetentionInDays;
167
161
  if (!retention) {
@@ -170,5 +164,4 @@ class StackCheckingAspect {
170
164
  }
171
165
  }
172
166
  }
173
- exports.StackCheckingAspect = StackCheckingAspect;
174
167
  //# sourceMappingURL=stack-checking-aspect.js.map
@@ -1,12 +1,11 @@
1
1
  import { Stack, StackProps } from "aws-cdk-lib";
2
- import { IVpc } from "aws-cdk-lib/aws-ec2";
3
- import { ISecurityGroup } from "aws-cdk-lib/aws-ec2/lib/security-group";
2
+ import { type ISecurityGroup, IVpc } from "aws-cdk-lib/aws-ec2";
4
3
  import { ITopic } from "aws-cdk-lib/aws-sns";
5
4
  import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
6
5
  import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
7
6
  import { Construct } from "constructs";
8
- import { TrafficType } from "../../../types/traffictype";
9
- import { DBLambdaEnvironment } from "./lambda-configs";
7
+ import { TrafficType } from "../../../types/traffictype.js";
8
+ import { DBLambdaEnvironment } from "./lambda-configs.js";
10
9
  export declare const SOLUTION_KEY = "Solution";
11
10
  export declare const SSM_KEY_WARNING_TOPIC = "/digitraffic/monitoring/warning-topic";
12
11
  export declare const SSM_KEY_ALARM_TOPIC = "/digitraffic/monitoring/alarm-topic";
@@ -1,28 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DigitrafficStack = exports.SSM_KEY_ALARM_TOPIC = exports.SSM_KEY_WARNING_TOPIC = exports.SOLUTION_KEY = void 0;
4
- const aws_cdk_lib_1 = require("aws-cdk-lib");
5
- const aws_ec2_1 = require("aws-cdk-lib/aws-ec2");
6
- const aws_sns_1 = require("aws-cdk-lib/aws-sns");
7
- const aws_ssm_1 = require("aws-cdk-lib/aws-ssm");
8
- const aws_secretsmanager_1 = require("aws-cdk-lib/aws-secretsmanager");
9
- const stack_checking_aspect_1 = require("./stack-checking-aspect");
1
+ import { Aspects, Stack } from "aws-cdk-lib";
2
+ import { SecurityGroup, Vpc } from "aws-cdk-lib/aws-ec2";
3
+ import { Topic } from "aws-cdk-lib/aws-sns";
4
+ import { StringParameter } from "aws-cdk-lib/aws-ssm";
5
+ import { Secret } from "aws-cdk-lib/aws-secretsmanager";
6
+ import { StackCheckingAspect } from "./stack-checking-aspect.js";
10
7
  const SSM_ROOT = "/digitraffic";
11
- exports.SOLUTION_KEY = "Solution";
8
+ export const SOLUTION_KEY = "Solution";
12
9
  const MONITORING_ROOT = "/monitoring";
13
- exports.SSM_KEY_WARNING_TOPIC = `${SSM_ROOT}${MONITORING_ROOT}/warning-topic`;
14
- exports.SSM_KEY_ALARM_TOPIC = `${SSM_ROOT}${MONITORING_ROOT}/alarm-topic`;
15
- class DigitrafficStack extends aws_cdk_lib_1.Stack {
10
+ export const SSM_KEY_WARNING_TOPIC = `${SSM_ROOT}${MONITORING_ROOT}/warning-topic`;
11
+ export const SSM_KEY_ALARM_TOPIC = `${SSM_ROOT}${MONITORING_ROOT}/alarm-topic`;
12
+ export class DigitrafficStack extends Stack {
16
13
  constructor(scope, id, configuration) {
17
14
  super(scope, id, configuration.stackProps);
18
15
  this.configuration = configuration;
19
16
  if (configuration.secretId) {
20
- this.secret = aws_secretsmanager_1.Secret.fromSecretNameV2(this, "Secret", configuration.secretId);
17
+ this.secret = Secret.fromSecretNameV2(this, "Secret", configuration.secretId);
21
18
  }
22
19
  // VPC reference construction requires vpcId and availability zones
23
20
  // private subnets are used in Lambda configuration
24
21
  if (configuration.vpcId) {
25
- this.vpc = aws_ec2_1.Vpc.fromVpcAttributes(this, "vpc", {
22
+ this.vpc = Vpc.fromVpcAttributes(this, "vpc", {
26
23
  vpcId: configuration.vpcId,
27
24
  privateSubnetIds: configuration.privateSubnetIds,
28
25
  availabilityZones: configuration.availabilityZones ?? [],
@@ -30,14 +27,14 @@ class DigitrafficStack extends aws_cdk_lib_1.Stack {
30
27
  }
31
28
  // security group that allows Lambda database access
32
29
  if (configuration.lambdaDbSgId) {
33
- this.lambdaDbSg = aws_ec2_1.SecurityGroup.fromSecurityGroupId(this, "LambdaDbSG", configuration.lambdaDbSgId);
30
+ this.lambdaDbSg = SecurityGroup.fromSecurityGroupId(this, "LambdaDbSG", configuration.lambdaDbSgId);
34
31
  }
35
- this.alarmTopic = aws_sns_1.Topic.fromTopicArn(this, "AlarmTopic", aws_ssm_1.StringParameter.fromStringParameterName(this, "AlarmTopicParam", exports.SSM_KEY_ALARM_TOPIC).stringValue);
36
- this.warningTopic = aws_sns_1.Topic.fromTopicArn(this, "WarningTopic", aws_ssm_1.StringParameter.fromStringParameterName(this, "WarningTopicParam", exports.SSM_KEY_WARNING_TOPIC).stringValue);
32
+ this.alarmTopic = Topic.fromTopicArn(this, "AlarmTopic", StringParameter.fromStringParameterName(this, "AlarmTopicParam", SSM_KEY_ALARM_TOPIC).stringValue);
33
+ this.warningTopic = Topic.fromTopicArn(this, "WarningTopic", StringParameter.fromStringParameterName(this, "WarningTopicParam", SSM_KEY_WARNING_TOPIC).stringValue);
37
34
  this.addAspects();
38
35
  }
39
36
  addAspects() {
40
- aws_cdk_lib_1.Aspects.of(this).add(stack_checking_aspect_1.StackCheckingAspect.create(this));
37
+ Aspects.of(this).add(StackCheckingAspect.create(this));
41
38
  }
42
39
  createLambdaEnvironment() {
43
40
  return this.createDefaultLambdaEnvironment(this.configuration.shortName);
@@ -63,5 +60,4 @@ class DigitrafficStack extends aws_cdk_lib_1.Stack {
63
60
  lambdas.forEach((l) => secret.grantRead(l));
64
61
  }
65
62
  }
66
- exports.DigitrafficStack = DigitrafficStack;
67
63
  //# sourceMappingURL=stack.js.map
@@ -1,8 +1,8 @@
1
1
  import { CfnSubscriptionFilter } from "aws-cdk-lib/aws-logs";
2
2
  import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
3
- import { DigitrafficStack } from "./stack";
3
+ import { DigitrafficStack } from "./stack.js";
4
4
  import { Construct } from "constructs";
5
- import { MonitoredFunction } from "./monitoredfunction";
5
+ import { MonitoredFunction } from "./monitoredfunction.js";
6
6
  /**
7
7
  * Creates a subscription filter that subscribes to a Lambda Log Group and delivers the logs to another destination.
8
8
  * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-subscriptionfilter.html
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DigitrafficLogSubscriptions = exports.createSubscription = void 0;
4
- const aws_logs_1 = require("aws-cdk-lib/aws-logs");
1
+ import { CfnSubscriptionFilter } from "aws-cdk-lib/aws-logs";
5
2
  /**
6
3
  * Creates a subscription filter that subscribes to a Lambda Log Group and delivers the logs to another destination.
7
4
  * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-subscriptionfilter.html
@@ -10,11 +7,11 @@ const aws_logs_1 = require("aws-cdk-lib/aws-logs");
10
7
  * @param logDestinationArn Destination for streamed logs
11
8
  * @param stack CloudFormation stack
12
9
  */
13
- function createSubscription(lambda, lambdaName, logDestinationArn, stack) {
10
+ export function createSubscription(lambda, lambdaName, logDestinationArn, stack) {
14
11
  if (logDestinationArn == undefined) {
15
12
  return undefined;
16
13
  }
17
- const filter = new aws_logs_1.CfnSubscriptionFilter(stack, `${lambdaName}LogsSubscription`, {
14
+ const filter = new CfnSubscriptionFilter(stack, `${lambdaName}LogsSubscription`, {
18
15
  logGroupName: `/aws/lambda/${lambdaName}`,
19
16
  filterPattern: "",
20
17
  destinationArn: logDestinationArn,
@@ -22,13 +19,12 @@ function createSubscription(lambda, lambdaName, logDestinationArn, stack) {
22
19
  filter.node.addDependency(lambda);
23
20
  return filter;
24
21
  }
25
- exports.createSubscription = createSubscription;
26
- class DigitrafficLogSubscriptions {
22
+ export class DigitrafficLogSubscriptions {
27
23
  constructor(stack, ...lambdas) {
28
24
  const destinationArn = stack.configuration.logsDestinationArn;
29
25
  if (destinationArn !== undefined) {
30
26
  lambdas.forEach((lambda) => {
31
- const filter = new aws_logs_1.CfnSubscriptionFilter(stack, `${lambda.givenName}LogsSubscription`, {
27
+ const filter = new CfnSubscriptionFilter(stack, `${lambda.givenName}LogsSubscription`, {
32
28
  logGroupName: `/aws/lambda/${lambda.givenName}`,
33
29
  filterPattern: "",
34
30
  destinationArn,
@@ -38,5 +34,4 @@ class DigitrafficLogSubscriptions {
38
34
  }
39
35
  }
40
36
  }
41
- exports.DigitrafficLogSubscriptions = DigitrafficLogSubscriptions;
42
37
  //# sourceMappingURL=subscription.js.map
@@ -1,6 +1,6 @@
1
1
  import { Stack } from "aws-cdk-lib";
2
- import { Construct } from "constructs/lib/construct";
3
- import { InfraStackConfiguration } from "./intra-stack-configuration";
2
+ import { type Construct } from "constructs";
3
+ import { InfraStackConfiguration } from "./intra-stack-configuration.js";
4
4
  /**
5
5
  * Creates a dns local zone and creates records for cluster endpoints and proxy endpoints.
6
6
  *
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DbDnsStack = void 0;
4
- const aws_cdk_lib_1 = require("aws-cdk-lib");
5
- const aws_route53_1 = require("aws-cdk-lib/aws-route53");
6
- const import_util_1 = require("../import-util");
7
- const parameters_1 = require("../stack/parameters");
8
- const DEFAULT_RECORD_TTL = aws_cdk_lib_1.Duration.seconds(30);
1
+ import { Duration, RemovalPolicy, Stack } from "aws-cdk-lib";
2
+ import { PrivateHostedZone, RecordSet, RecordTarget, RecordType, } from "aws-cdk-lib/aws-route53";
3
+ import { importVpc } from "../import-util.js";
4
+ import { getParameterValue } from "../stack/parameters.js";
5
+ const DEFAULT_RECORD_TTL = Duration.seconds(30);
9
6
  /**
10
7
  * Creates a dns local zone and creates records for cluster endpoints and proxy endpoints.
11
8
  *
12
9
  * Please note, that created PrivateHostedZone has RETAIN removalPolicy, so if you want to delete this stack,
13
10
  * you must remove the zone by hand after.
14
11
  */
15
- class DbDnsStack extends aws_cdk_lib_1.Stack {
12
+ export class DbDnsStack extends Stack {
16
13
  constructor(scope, id, isc) {
17
14
  super(scope, id, {
18
15
  env: isc.env,
@@ -20,45 +17,44 @@ class DbDnsStack extends aws_cdk_lib_1.Stack {
20
17
  this.createDnsRecords(isc);
21
18
  }
22
19
  createDnsRecords(isc) {
23
- const vpc = (0, import_util_1.importVpc)(this, isc.environmentName);
24
- const zone = new aws_route53_1.PrivateHostedZone(this, "DNSHostedZone", {
20
+ const vpc = importVpc(this, isc.environmentName);
21
+ const zone = new PrivateHostedZone(this, "DNSHostedZone", {
25
22
  zoneName: isc.environmentName + ".local",
26
23
  vpc,
27
24
  });
28
- zone.applyRemovalPolicy(aws_cdk_lib_1.RemovalPolicy.RETAIN);
29
- const clusterReaderEndpoint = (0, parameters_1.getParameterValue)(this, "cluster.reader");
30
- const clusterWriterEndpoint = (0, parameters_1.getParameterValue)(this, "cluster.writer");
31
- const proxyReaderEndpoint = (0, parameters_1.getParameterValue)(this, "proxy.reader");
32
- const proxyWriterEndpoint = (0, parameters_1.getParameterValue)(this, "proxy.writer");
33
- new aws_route53_1.RecordSet(this, "ReaderRecord", {
34
- recordType: aws_route53_1.RecordType.CNAME,
25
+ zone.applyRemovalPolicy(RemovalPolicy.RETAIN);
26
+ const clusterReaderEndpoint = getParameterValue(this, "cluster.reader");
27
+ const clusterWriterEndpoint = getParameterValue(this, "cluster.writer");
28
+ const proxyReaderEndpoint = getParameterValue(this, "proxy.reader");
29
+ const proxyWriterEndpoint = getParameterValue(this, "proxy.writer");
30
+ new RecordSet(this, "ReaderRecord", {
31
+ recordType: RecordType.CNAME,
35
32
  recordName: `db-ro.${isc.environmentName}.local`,
36
- target: aws_route53_1.RecordTarget.fromValues(clusterReaderEndpoint),
33
+ target: RecordTarget.fromValues(clusterReaderEndpoint),
37
34
  ttl: DEFAULT_RECORD_TTL,
38
35
  zone,
39
36
  });
40
- new aws_route53_1.RecordSet(this, "WriterRecord", {
41
- recordType: aws_route53_1.RecordType.CNAME,
37
+ new RecordSet(this, "WriterRecord", {
38
+ recordType: RecordType.CNAME,
42
39
  recordName: `db.${isc.environmentName}.local`,
43
- target: aws_route53_1.RecordTarget.fromValues(clusterWriterEndpoint),
40
+ target: RecordTarget.fromValues(clusterWriterEndpoint),
44
41
  ttl: DEFAULT_RECORD_TTL,
45
42
  zone,
46
43
  });
47
- new aws_route53_1.RecordSet(this, "ProxyReaderRecord", {
48
- recordType: aws_route53_1.RecordType.CNAME,
44
+ new RecordSet(this, "ProxyReaderRecord", {
45
+ recordType: RecordType.CNAME,
49
46
  recordName: `proxy-ro.${isc.environmentName}.local`,
50
- target: aws_route53_1.RecordTarget.fromValues(proxyReaderEndpoint),
47
+ target: RecordTarget.fromValues(proxyReaderEndpoint),
51
48
  ttl: DEFAULT_RECORD_TTL,
52
49
  zone,
53
50
  });
54
- new aws_route53_1.RecordSet(this, "ProxyWriterRecord", {
55
- recordType: aws_route53_1.RecordType.CNAME,
51
+ new RecordSet(this, "ProxyWriterRecord", {
52
+ recordType: RecordType.CNAME,
56
53
  recordName: `proxy.${isc.environmentName}.local`,
57
- target: aws_route53_1.RecordTarget.fromValues(proxyWriterEndpoint),
54
+ target: RecordTarget.fromValues(proxyWriterEndpoint),
58
55
  ttl: DEFAULT_RECORD_TTL,
59
56
  zone,
60
57
  });
61
58
  }
62
59
  }
63
- exports.DbDnsStack = DbDnsStack;
64
60
  //# sourceMappingURL=db-dns-stack.js.map
@@ -1,9 +1,9 @@
1
1
  import { CfnDBProxyEndpoint, DatabaseProxy } from "aws-cdk-lib/aws-rds";
2
2
  import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
3
3
  import { IVpc } from "aws-cdk-lib/aws-ec2";
4
- import { InfraStackConfiguration } from "./intra-stack-configuration";
4
+ import { InfraStackConfiguration } from "./intra-stack-configuration.js";
5
5
  import { Stack } from "aws-cdk-lib/core";
6
- import { Construct } from "constructs/lib/construct";
6
+ import { Construct } from "constructs/lib/construct.js";
7
7
  export interface ProxyConfiguration {
8
8
  readonly secretArn: string;
9
9
  readonly name?: string;
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DbProxyStack = void 0;
4
- const aws_rds_1 = require("aws-cdk-lib/aws-rds");
5
- const aws_secretsmanager_1 = require("aws-cdk-lib/aws-secretsmanager");
6
- const aws_ec2_1 = require("aws-cdk-lib/aws-ec2");
7
- const db_stack_1 = require("./db-stack");
8
- const import_util_1 = require("../import-util");
9
- const parameters_1 = require("../stack/parameters");
10
- const core_1 = require("aws-cdk-lib/core");
1
+ import { CfnDBProxyEndpoint, DatabaseCluster, DatabaseClusterEngine, DatabaseProxy, ProxyTarget, } from "aws-cdk-lib/aws-rds";
2
+ import { Secret } from "aws-cdk-lib/aws-secretsmanager";
3
+ import { SecurityGroup } from "aws-cdk-lib/aws-ec2";
4
+ import { DbStack } from "./db-stack.js";
5
+ import { exportValue, importVpc } from "../import-util.js";
6
+ import { createParameter } from "../stack/parameters.js";
7
+ import { Stack, Duration } from "aws-cdk-lib/core";
11
8
  /**
12
9
  * A stack that creates a Database proxy.
13
10
  */
14
- class DbProxyStack extends core_1.Stack {
11
+ export class DbProxyStack extends Stack {
15
12
  constructor(scope, id, isc, configuration) {
16
13
  super(scope, id, {
17
14
  env: isc.env,
@@ -20,49 +17,49 @@ class DbProxyStack extends core_1.Stack {
20
17
  if (configuration.clusterIdentifier === "") {
21
18
  throw new Error("Empty cluster identifier!");
22
19
  }
23
- const vpc = (0, import_util_1.importVpc)(this, isc.environmentName);
24
- const secret = aws_secretsmanager_1.Secret.fromSecretAttributes(this, "proxy-secret", {
20
+ const vpc = importVpc(this, isc.environmentName);
21
+ const secret = Secret.fromSecretAttributes(this, "proxy-secret", {
25
22
  secretCompleteArn: configuration.secretArn,
26
23
  });
27
24
  const proxy = this.createProxy(vpc, secret, configuration);
28
25
  const readerEndpoint = this.createProxyEndpoints(vpc, proxy, configuration.securityGroupId);
29
- (0, parameters_1.createParameter)(this, "proxy.reader", readerEndpoint.attrEndpoint);
30
- (0, parameters_1.createParameter)(this, "proxy.writer", proxy.endpoint);
26
+ createParameter(this, "proxy.reader", readerEndpoint.attrEndpoint);
27
+ createParameter(this, "proxy.writer", proxy.endpoint);
31
28
  this.setOutputs(proxy);
32
29
  }
33
30
  setOutputs(proxy) {
34
31
  // if only one instance, then there is no reader-endpoint
35
- (0, import_util_1.exportValue)(this, this.isc.environmentName, DbProxyStack.PROXY_READER_EXPORT_NAME, proxy.endpoint);
36
- (0, import_util_1.exportValue)(this, this.isc.environmentName, DbProxyStack.PROXY_WRITER_EXPORT_NAME, proxy.endpoint);
32
+ exportValue(this, this.isc.environmentName, DbProxyStack.PROXY_READER_EXPORT_NAME, proxy.endpoint);
33
+ exportValue(this, this.isc.environmentName, DbProxyStack.PROXY_WRITER_EXPORT_NAME, proxy.endpoint);
37
34
  }
38
35
  createProxy(vpc, secret, configuration) {
39
36
  const proxyId = `${this.isc.environmentName}-proxy`;
40
- const securityGroup = aws_ec2_1.SecurityGroup.fromSecurityGroupId(this, "securitygroup", configuration.securityGroupId);
41
- const cluster = aws_rds_1.DatabaseCluster.fromDatabaseClusterAttributes(this, "db-cluster", {
37
+ const securityGroup = SecurityGroup.fromSecurityGroupId(this, "securitygroup", configuration.securityGroupId);
38
+ const cluster = DatabaseCluster.fromDatabaseClusterAttributes(this, "db-cluster", {
42
39
  clusterIdentifier: configuration.clusterIdentifier,
43
- engine: aws_rds_1.DatabaseClusterEngine.AURORA_POSTGRESQL,
44
- port: db_stack_1.DbStack.CLUSTER_PORT,
40
+ engine: DatabaseClusterEngine.AURORA_POSTGRESQL,
41
+ port: DbStack.CLUSTER_PORT,
45
42
  });
46
43
  // CDK tries to allow connections between proxy and cluster
47
44
  // this does not work on cluster references
48
45
  cluster.connections.allowDefaultPortFrom = () => {
49
46
  /* nothing */
50
47
  };
51
- return new aws_rds_1.DatabaseProxy(this, proxyId, {
48
+ return new DatabaseProxy(this, proxyId, {
52
49
  dbProxyName: configuration.name ?? "AuroraProxy",
53
50
  securityGroups: [securityGroup],
54
- proxyTarget: aws_rds_1.ProxyTarget.fromCluster(cluster),
55
- idleClientTimeout: core_1.Duration.seconds(1800),
51
+ proxyTarget: ProxyTarget.fromCluster(cluster),
52
+ idleClientTimeout: Duration.seconds(1800),
56
53
  maxConnectionsPercent: 50,
57
54
  maxIdleConnectionsPercent: 25,
58
- borrowTimeout: core_1.Duration.seconds(120),
55
+ borrowTimeout: Duration.seconds(120),
59
56
  requireTLS: false,
60
57
  secrets: [secret],
61
58
  vpc: vpc,
62
59
  });
63
60
  }
64
61
  createProxyEndpoints(vpc, proxy, securityGroupId) {
65
- return new aws_rds_1.CfnDBProxyEndpoint(this, "ReaderEndpoint", {
62
+ return new CfnDBProxyEndpoint(this, "ReaderEndpoint", {
66
63
  dbProxyEndpointName: "ReaderEndpoint",
67
64
  dbProxyName: proxy.dbProxyName,
68
65
  vpcSubnetIds: vpc.privateSubnets.map((sub) => sub.subnetId),
@@ -71,7 +68,6 @@ class DbProxyStack extends core_1.Stack {
71
68
  });
72
69
  }
73
70
  }
74
- exports.DbProxyStack = DbProxyStack;
75
71
  DbProxyStack.PROXY_READER_EXPORT_NAME = "db-reader-endpoint";
76
72
  DbProxyStack.PROXY_WRITER_EXPORT_NAME = "db-writer-endpoint";
77
73
  //# sourceMappingURL=db-proxy-stack.js.map
@@ -1,8 +1,7 @@
1
- import { InstanceType, IVpc } from "aws-cdk-lib/aws-ec2";
2
- import { ISecurityGroup } from "aws-cdk-lib/aws-ec2/lib/security-group";
1
+ import { InstanceType, IVpc, type ISecurityGroup } from "aws-cdk-lib/aws-ec2";
3
2
  import { AuroraPostgresEngineVersion, DatabaseCluster, DatabaseClusterProps, IParameterGroup } from "aws-cdk-lib/aws-rds";
4
- import { Construct } from "constructs/lib/construct";
5
- import { InfraStackConfiguration } from "./intra-stack-configuration";
3
+ import { Construct } from "constructs/lib/construct.js";
4
+ import { InfraStackConfiguration } from "./intra-stack-configuration.js";
6
5
  import { Stack } from "aws-cdk-lib/core";
7
6
  export interface DbConfiguration {
8
7
  readonly cluster?: ClusterConfiguration;