@digitraffic/common 2023.5.25-1 → 2023.5.31-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.
@@ -5,6 +5,9 @@ import { AuroraPostgresEngineVersion, DatabaseCluster, DatabaseClusterProps, IPa
5
5
  import { Construct } from "constructs";
6
6
  import { InfraStackConfiguration } from "./intra-stack-configuration";
7
7
  export interface DbConfiguration {
8
+ /** superuser username and password are fetched from this secret, using keys
9
+ * db.superuser and db.superuser.password
10
+ */
8
11
  readonly secretArn: string;
9
12
  readonly dbVersion: AuroraPostgresEngineVersion;
10
13
  readonly dbInstanceType: InstanceType;
@@ -12,6 +15,8 @@ export interface DbConfiguration {
12
15
  readonly instances: number;
13
16
  readonly customParameterGroup: boolean;
14
17
  readonly securityGroupId: string;
18
+ /** If this is not specified, import default vpc */
19
+ readonly vpcId?: string;
15
20
  readonly proxy: {
16
21
  readonly name?: string;
17
22
  readonly securityGroupId: string;
@@ -75,13 +75,20 @@ class DbStack extends aws_cdk_lib_1.Stack {
75
75
  },
76
76
  credentials: aws_rds_1.Credentials.fromPassword(secret.secretValueFromJson("db.superuser").unsafeUnwrap(), secret.secretValueFromJson("db.superuser.password")),
77
77
  parameterGroup,
78
+ storageEncrypted: true,
79
+ monitoringInterval: aws_cdk_lib_1.Duration.seconds(30),
78
80
  };
79
81
  }
80
82
  createAuroraCluster(isc, configuration) {
81
83
  const instanceName = isc.environmentName + "-db";
82
84
  const securityGroup = aws_ec2_1.SecurityGroup.fromSecurityGroupId(this, "securitygroup", configuration.securityGroupId);
83
85
  const parameterGroup = this.createParamaterGroup(configuration);
84
- const parameters = this.createClusterParameters(configuration, instanceName, (0, import_util_1.importVpc)(this, isc.environmentName), securityGroup, parameterGroup);
86
+ const vpc = configuration.vpcId
87
+ ? aws_ec2_1.Vpc.fromLookup(this, "vpc", {
88
+ vpcId: configuration.vpcId,
89
+ })
90
+ : (0, import_util_1.importVpc)(this, isc.environmentName);
91
+ const parameters = this.createClusterParameters(configuration, instanceName, vpc, securityGroup, parameterGroup);
85
92
  // create cluster from the snapshot or from the scratch
86
93
  const cluster = configuration.snapshotIdentifier
87
94
  ? new aws_rds_1.DatabaseClusterFromSnapshot(this, instanceName, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitraffic/common",
3
- "version": "2023.5.25-1",
3
+ "version": "2023.5.31-1",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,10 +37,10 @@
37
37
  "@types/geojson": "^7946.0.10",
38
38
  "@types/etag": "^1.8.1",
39
39
  "@types/jest": "^29.5.1",
40
- "@types/lodash": "^4.14.194",
40
+ "@types/lodash": "^4.14.195",
41
41
  "@types/node": "18.15.13",
42
42
  "@types/ramda": "~0.29.1",
43
- "@types/sinon": "10.0.14",
43
+ "@types/sinon": "10.0.15",
44
44
  "@typescript-eslint/eslint-plugin": "~5.59.5",
45
45
  "@typescript-eslint/parser": "^5.59.5",
46
46
  "aws-cdk-lib": "~2.78.0",
@@ -51,19 +51,21 @@
51
51
  "eslint": "~8.40.0",
52
52
  "eslint-config-prettier": "^8.8.0",
53
53
  "eslint-plugin-deprecation": "~1.4.1",
54
+ "etag": "^1.8.1",
54
55
  "geojson-validation": "^1.0.2",
55
56
  "husky": "^8.0.3",
56
57
  "jest": "^29.5.0",
57
58
  "jest-junit": "^16.0.0",
58
59
  "lint-staged": "^13.2.2",
60
+ "lodash": "^4.17.21",
59
61
  "moment": "^2.29.4",
60
62
  "node-ttl": "^0.2.0",
61
63
  "pg-native": "^3.0.1",
62
64
  "pg-promise": "^11.4.3",
63
65
  "prettier": "^2.8.8",
64
66
  "ramda": "~0.29.0",
65
- "rimraf": "^5.0.0",
66
- "sinon": "15.0.4",
67
+ "rimraf": "^5.0.1",
68
+ "sinon": "15.1.0",
67
69
  "ts-jest": "^29.1.0",
68
70
  "typescript": "~4.9.5",
69
71
  "velocityjs": "2.0.6"
@@ -75,9 +77,6 @@
75
77
  "lint-staged": {
76
78
  "*.{js,ts,css,md,yml,yaml,json}": "prettier --write"
77
79
  },
78
- "dependencies": {
79
- "lodash": "^4.17.21"
80
- },
81
80
  "scripts": {
82
81
  "build": "tsc",
83
82
  "lint": "eslint --cache .",
@@ -4,6 +4,7 @@ import {
4
4
  IVpc,
5
5
  SecurityGroup,
6
6
  SubnetType,
7
+ Vpc,
7
8
  } from "aws-cdk-lib/aws-ec2";
8
9
  import { ISecurityGroup } from "aws-cdk-lib/aws-ec2/lib/security-group";
9
10
  import {
@@ -24,6 +25,9 @@ import { InfraStackConfiguration } from "./intra-stack-configuration";
24
25
  import { exportValue, importVpc } from "../import-util";
25
26
 
26
27
  export interface DbConfiguration {
28
+ /** superuser username and password are fetched from this secret, using keys
29
+ * db.superuser and db.superuser.password
30
+ */
27
31
  readonly secretArn: string;
28
32
 
29
33
  readonly dbVersion: AuroraPostgresEngineVersion;
@@ -32,6 +36,8 @@ export interface DbConfiguration {
32
36
  readonly instances: number;
33
37
  readonly customParameterGroup: boolean;
34
38
  readonly securityGroupId: string;
39
+ /** If this is not specified, import default vpc */
40
+ readonly vpcId?: string;
35
41
 
36
42
  readonly proxy: {
37
43
  readonly name?: string;
@@ -163,6 +169,8 @@ export class DbStack extends Stack {
163
169
  secret.secretValueFromJson("db.superuser.password")
164
170
  ),
165
171
  parameterGroup,
172
+ storageEncrypted: true,
173
+ monitoringInterval: Duration.seconds(30),
166
174
  };
167
175
  }
168
176
 
@@ -177,10 +185,16 @@ export class DbStack extends Stack {
177
185
  configuration.securityGroupId
178
186
  );
179
187
  const parameterGroup = this.createParamaterGroup(configuration);
188
+ const vpc = configuration.vpcId
189
+ ? Vpc.fromLookup(this, "vpc", {
190
+ vpcId: configuration.vpcId,
191
+ })
192
+ : importVpc(this, isc.environmentName);
193
+
180
194
  const parameters = this.createClusterParameters(
181
195
  configuration,
182
196
  instanceName,
183
- importVpc(this, isc.environmentName),
197
+ vpc,
184
198
  securityGroup,
185
199
  parameterGroup
186
200
  );
@@ -35,6 +35,6 @@ export function dateFromIsoString(isoString: string): Date {
35
35
  return parsed;
36
36
  }
37
37
 
38
- function isValidDate(d: any) {
38
+ function isValidDate(d: unknown) {
39
39
  return d instanceof Date && !isNaN(d.getTime());
40
40
  }