@digitraffic/common 2023.2.1-1 → 2023.2.13-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.
@@ -52,9 +52,19 @@ class DigitrafficStaticIntegration extends aws_apigateway_1.MockIntegration {
|
|
52
52
|
}
|
53
53
|
static createMethodResponse(enableCors) {
|
54
54
|
return enableCors
|
55
|
-
?
|
55
|
+
? corsMethod(METHOD_RESPONSE_200)
|
56
56
|
: METHOD_RESPONSE_200;
|
57
57
|
}
|
58
58
|
}
|
59
59
|
exports.DigitrafficStaticIntegration = DigitrafficStaticIntegration;
|
60
|
+
function corsMethod(response) {
|
61
|
+
return {
|
62
|
+
...response,
|
63
|
+
...{
|
64
|
+
responseParameters: {
|
65
|
+
"method.response.header.Access-Control-Allow-Origin": true,
|
66
|
+
},
|
67
|
+
},
|
68
|
+
};
|
69
|
+
}
|
60
70
|
//# sourceMappingURL=static-integration.js.map
|
@@ -1,11 +1,9 @@
|
|
1
1
|
import { Stack } from "aws-cdk-lib";
|
2
|
-
import {
|
3
|
-
import {
|
2
|
+
import { InstanceType, IVpc } from "aws-cdk-lib/aws-ec2";
|
3
|
+
import { ISecurityGroup } from "aws-cdk-lib/aws-ec2/lib/security-group";
|
4
4
|
import { AuroraPostgresEngineVersion, DatabaseCluster, DatabaseClusterProps, IParameterGroup } from "aws-cdk-lib/aws-rds";
|
5
|
-
import {
|
6
|
-
import { InstanceType } from "aws-cdk-lib/aws-ec2";
|
5
|
+
import { Construct } from "constructs";
|
7
6
|
import { InfraStackConfiguration } from "./intra-stack-configuration";
|
8
|
-
import { ISecurityGroup } from "aws-cdk-lib/aws-ec2/lib/security-group";
|
9
7
|
export interface DbConfiguration {
|
10
8
|
readonly secretArn: string;
|
11
9
|
readonly dbVersion: AuroraPostgresEngineVersion;
|
@@ -14,6 +12,8 @@ export interface DbConfiguration {
|
|
14
12
|
readonly instances: number;
|
15
13
|
readonly customParameterGroup: boolean;
|
16
14
|
readonly securityGroupId: string;
|
15
|
+
readonly superuserName: string;
|
16
|
+
readonly superuserPassword: string;
|
17
17
|
readonly proxy: {
|
18
18
|
readonly name?: string;
|
19
19
|
readonly securityGroupId: string;
|
@@ -34,6 +34,6 @@ export declare class DbStack extends Stack {
|
|
34
34
|
static CLUSTER_PORT: number;
|
35
35
|
constructor(scope: Construct, id: string, isc: InfraStackConfiguration, configuration: DbConfiguration);
|
36
36
|
createParamaterGroup(configuration: DbConfiguration): IParameterGroup;
|
37
|
-
createClusterParameters(configuration: DbConfiguration, instanceName: string, vpc: IVpc, securityGroup: ISecurityGroup, parameterGroup: IParameterGroup
|
37
|
+
createClusterParameters(configuration: DbConfiguration, instanceName: string, vpc: IVpc, securityGroup: ISecurityGroup, parameterGroup: IParameterGroup): DatabaseClusterProps;
|
38
38
|
createAuroraCluster(isc: InfraStackConfiguration, configuration: DbConfiguration): DatabaseCluster;
|
39
39
|
}
|
@@ -4,7 +4,6 @@ exports.DbStack = void 0;
|
|
4
4
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
5
5
|
const aws_ec2_1 = require("aws-cdk-lib/aws-ec2");
|
6
6
|
const aws_rds_1 = require("aws-cdk-lib/aws-rds");
|
7
|
-
const aws_secretsmanager_1 = require("aws-cdk-lib/aws-secretsmanager");
|
8
7
|
const import_util_1 = require("../import-util");
|
9
8
|
/**
|
10
9
|
* How to upgrade major version?
|
@@ -38,7 +37,7 @@ class DbStack extends aws_cdk_lib_1.Stack {
|
|
38
37
|
})
|
39
38
|
: aws_rds_1.ParameterGroup.fromParameterGroupName(this, "ParameterGroup", `default.aurora-postgresql${configuration.dbVersion.auroraPostgresMajorVersion}`);
|
40
39
|
}
|
41
|
-
createClusterParameters(configuration, instanceName, vpc, securityGroup, parameterGroup
|
40
|
+
createClusterParameters(configuration, instanceName, vpc, securityGroup, parameterGroup) {
|
42
41
|
return {
|
43
42
|
engine: aws_rds_1.DatabaseClusterEngine.auroraPostgres({
|
44
43
|
version: configuration.dbVersion,
|
@@ -67,19 +66,16 @@ class DbStack extends aws_cdk_lib_1.Stack {
|
|
67
66
|
instanceType: configuration.dbInstanceType,
|
68
67
|
parameterGroup,
|
69
68
|
},
|
70
|
-
credentials: aws_rds_1.Credentials.
|
69
|
+
credentials: aws_rds_1.Credentials.fromPassword(configuration.superuserName, aws_cdk_lib_1.SecretValue.unsafePlainText(configuration.superuserPassword)),
|
71
70
|
parameterGroup,
|
72
71
|
};
|
73
72
|
}
|
74
73
|
createAuroraCluster(isc, configuration) {
|
75
74
|
const instanceName = isc.environmentName + "-db";
|
76
|
-
const secret = aws_secretsmanager_1.Secret.fromSecretAttributes(this, "db-secret", {
|
77
|
-
secretCompleteArn: configuration.secretArn,
|
78
|
-
});
|
79
75
|
const securityGroup = aws_ec2_1.SecurityGroup.fromSecurityGroupId(this, "securitygroup", configuration.securityGroupId);
|
80
|
-
const vpc = (0, import_util_1.importVpc)(this, isc.environmentName);
|
81
76
|
const parameterGroup = this.createParamaterGroup(configuration);
|
82
|
-
const parameters = this.createClusterParameters(configuration, instanceName,
|
77
|
+
const parameters = this.createClusterParameters(configuration, instanceName, (0, import_util_1.importVpc)(this, isc.environmentName), securityGroup, parameterGroup);
|
78
|
+
// create cluster from the snapshot or from the scratch
|
83
79
|
const cluster = configuration.snapshotIdentifier
|
84
80
|
? new aws_rds_1.DatabaseClusterFromSnapshot(this, instanceName, {
|
85
81
|
...parameters,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@digitraffic/common",
|
3
|
-
"version": "2023.02.
|
3
|
+
"version": "2023.02.13-1",
|
4
4
|
"description": "",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -19,7 +19,7 @@
|
|
19
19
|
"peerDependencies": {
|
20
20
|
"@aws-cdk/aws-synthetics-alpha": "2.62.2-alpha.0",
|
21
21
|
"@types/geojson": "^7946.0.10",
|
22
|
-
"aws-cdk-lib": "
|
22
|
+
"aws-cdk-lib": "2.62.2",
|
23
23
|
"aws-sdk": "^2.1304.0",
|
24
24
|
"axios": "^1.2.6",
|
25
25
|
"change-case": "^4.1.2",
|
@@ -35,24 +35,24 @@
|
|
35
35
|
"@types/aws-lambda": "^8.10.110",
|
36
36
|
"@types/geojson": "^7946.0.10",
|
37
37
|
"@types/jest": "^29.2.5",
|
38
|
-
"@types/node": "^18.
|
39
|
-
"@types/ramda": "^0.28.
|
38
|
+
"@types/node": "^18.13.0",
|
39
|
+
"@types/ramda": "^0.28.23",
|
40
40
|
"@types/sinon": "^10.0.13",
|
41
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
42
|
-
"@typescript-eslint/parser": "^5.
|
43
|
-
"aws-cdk-lib": "
|
41
|
+
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
42
|
+
"@typescript-eslint/parser": "^5.51.0",
|
43
|
+
"aws-cdk-lib": "2.62.2",
|
44
44
|
"aws-sdk": "^2.1304.0",
|
45
45
|
"axios": "^1.2.6",
|
46
46
|
"change-case": "^4.1.2",
|
47
47
|
"constructs": "^10.1.222",
|
48
|
-
"eslint": "^8.
|
48
|
+
"eslint": "^8.34.0",
|
49
49
|
"eslint-config-prettier": "^8.6.0",
|
50
50
|
"eslint-plugin-deprecation": "1.3.3",
|
51
51
|
"geojson-validation": "^1.0.2",
|
52
52
|
"husky": "^8.0.3",
|
53
|
-
"jest": "^29.
|
53
|
+
"jest": "^29.4.2",
|
54
54
|
"jest-junit": "^15.0.0",
|
55
|
-
"lint-staged": "^13.1.
|
55
|
+
"lint-staged": "^13.1.1",
|
56
56
|
"moment": "^2.29.4",
|
57
57
|
"node-ttl": "^0.2.0",
|
58
58
|
"pg-native": "^3.0.1",
|
@@ -62,7 +62,7 @@
|
|
62
62
|
"rimraf": "^4.1.0",
|
63
63
|
"sinon": "^15.0.1",
|
64
64
|
"ts-jest": "^29.0.5",
|
65
|
-
"typescript": "^4.9.
|
65
|
+
"typescript": "^4.9.5"
|
66
66
|
},
|
67
67
|
"externals": [
|
68
68
|
"aws-sdk",
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import {
|
2
|
+
MethodResponse,
|
2
3
|
MockIntegration,
|
3
4
|
PassthroughBehavior,
|
4
5
|
Resource,
|
5
6
|
} from "aws-cdk-lib/aws-apigateway";
|
6
7
|
import { MediaType } from "../../types/mediatypes";
|
7
|
-
import {
|
8
|
+
import { RESPONSE_CORS_INTEGRATION } from "./responses";
|
8
9
|
|
9
10
|
const INTEGRATION_RESPONSE_200 = `{
|
10
11
|
"statusCode": 200
|
@@ -94,3 +95,14 @@ export class DigitrafficStaticIntegration extends MockIntegration {
|
|
94
95
|
: METHOD_RESPONSE_200;
|
95
96
|
}
|
96
97
|
}
|
98
|
+
|
99
|
+
function corsMethod(response: MethodResponse): MethodResponse {
|
100
|
+
return {
|
101
|
+
...response,
|
102
|
+
...{
|
103
|
+
responseParameters: {
|
104
|
+
"method.response.header.Access-Control-Allow-Origin": true,
|
105
|
+
},
|
106
|
+
},
|
107
|
+
};
|
108
|
+
}
|
@@ -1,6 +1,11 @@
|
|
1
|
-
import { Duration, RemovalPolicy, Stack } from "aws-cdk-lib";
|
2
|
-
import {
|
3
|
-
|
1
|
+
import { Duration, RemovalPolicy, SecretValue, Stack } from "aws-cdk-lib";
|
2
|
+
import {
|
3
|
+
InstanceType,
|
4
|
+
IVpc,
|
5
|
+
SecurityGroup,
|
6
|
+
SubnetType,
|
7
|
+
} from "aws-cdk-lib/aws-ec2";
|
8
|
+
import { ISecurityGroup } from "aws-cdk-lib/aws-ec2/lib/security-group";
|
4
9
|
import {
|
5
10
|
AuroraPostgresEngineVersion,
|
6
11
|
CfnDBInstance,
|
@@ -13,11 +18,9 @@ import {
|
|
13
18
|
IParameterGroup,
|
14
19
|
ParameterGroup,
|
15
20
|
} from "aws-cdk-lib/aws-rds";
|
16
|
-
import {
|
21
|
+
import { Construct } from "constructs";
|
17
22
|
import { exportValue, importVpc } from "../import-util";
|
18
|
-
import { InstanceType } from "aws-cdk-lib/aws-ec2";
|
19
23
|
import { InfraStackConfiguration } from "./intra-stack-configuration";
|
20
|
-
import { ISecurityGroup } from "aws-cdk-lib/aws-ec2/lib/security-group";
|
21
24
|
|
22
25
|
export interface DbConfiguration {
|
23
26
|
readonly secretArn: string;
|
@@ -29,6 +32,9 @@ export interface DbConfiguration {
|
|
29
32
|
readonly customParameterGroup: boolean;
|
30
33
|
readonly securityGroupId: string;
|
31
34
|
|
35
|
+
readonly superuserName: string;
|
36
|
+
readonly superuserPassword: string;
|
37
|
+
|
32
38
|
readonly proxy: {
|
33
39
|
readonly name?: string;
|
34
40
|
readonly securityGroupId: string;
|
@@ -113,8 +119,7 @@ export class DbStack extends Stack {
|
|
113
119
|
instanceName: string,
|
114
120
|
vpc: IVpc,
|
115
121
|
securityGroup: ISecurityGroup,
|
116
|
-
parameterGroup: IParameterGroup
|
117
|
-
secret: ISecret
|
122
|
+
parameterGroup: IParameterGroup
|
118
123
|
): DatabaseClusterProps {
|
119
124
|
return {
|
120
125
|
engine: DatabaseClusterEngine.auroraPostgres({
|
@@ -144,7 +149,10 @@ export class DbStack extends Stack {
|
|
144
149
|
instanceType: configuration.dbInstanceType,
|
145
150
|
parameterGroup,
|
146
151
|
},
|
147
|
-
credentials: Credentials.
|
152
|
+
credentials: Credentials.fromPassword(
|
153
|
+
configuration.superuserName,
|
154
|
+
SecretValue.unsafePlainText(configuration.superuserPassword)
|
155
|
+
),
|
148
156
|
parameterGroup,
|
149
157
|
};
|
150
158
|
}
|
@@ -154,24 +162,21 @@ export class DbStack extends Stack {
|
|
154
162
|
configuration: DbConfiguration
|
155
163
|
): DatabaseCluster {
|
156
164
|
const instanceName = isc.environmentName + "-db";
|
157
|
-
const secret = Secret.fromSecretAttributes(this, "db-secret", {
|
158
|
-
secretCompleteArn: configuration.secretArn,
|
159
|
-
});
|
160
165
|
const securityGroup = SecurityGroup.fromSecurityGroupId(
|
161
166
|
this,
|
162
167
|
"securitygroup",
|
163
168
|
configuration.securityGroupId
|
164
169
|
);
|
165
|
-
const vpc = importVpc(this, isc.environmentName);
|
166
170
|
const parameterGroup = this.createParamaterGroup(configuration);
|
167
171
|
const parameters = this.createClusterParameters(
|
168
172
|
configuration,
|
169
173
|
instanceName,
|
170
|
-
|
174
|
+
importVpc(this, isc.environmentName),
|
171
175
|
securityGroup,
|
172
|
-
parameterGroup
|
173
|
-
secret
|
176
|
+
parameterGroup
|
174
177
|
);
|
178
|
+
|
179
|
+
// create cluster from the snapshot or from the scratch
|
175
180
|
const cluster = configuration.snapshotIdentifier
|
176
181
|
? new DatabaseClusterFromSnapshot(this, instanceName, {
|
177
182
|
...parameters,
|