Skip to content

Commit 623db4b

Browse files
committed
Init commit
1 parent 6f2c825 commit 623db4b

File tree

12 files changed

+145
-202
lines changed

12 files changed

+145
-202
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
!jest.config.js
22
node_modules
3-
invoke.sh
3+
44

55
# CDK asset staging directory
66
.cdk.staging
77
cdk.out
88
config.ts
99
cdk-infra.json
10-
config.ts
1110

1211
#App
1312
app/web/.env

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Graph Application using Amazon Neptune
22

3+
## Architecture overview
4+
5+
![Archiecture overview](./docs/images/architecture.png)
6+
37
## Prerequisites
48

59
- Node.js >= 18.19.0
610
- An AWS Account
7-
- AWS CLI
11+
- AWS CDK CLI
812
- Configuration and credential file settings
913
- See [the doc](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) in detail
1014
- Docker
@@ -20,7 +24,6 @@ Copy `config.sample.ts` and paste the file as `config.ts`. Then modify the `base
2024
const baseConfig = {
2125
appName: "graphApp",
2226
region: "us-east-1",
23-
buildApiWithCDK: true,
2427
adminEmail: "[email protected]",
2528
allowedIps: [],
2629
wafParamName: "graphAppWafWebACLID",
@@ -123,15 +126,11 @@ End streaming response%
123126

124127
## Useful commands
125128

126-
- `npm run deployInfra`
127-
129+
- `npm run deployBackend`
128130
- Deploy the infrastructure stack with AWS CDK
129-
130131
- `npm run deployFrontend`
131-
132132
- Deploy the frontend stack with AWS CDK
133-
134-
- `npm run destroyInfra`
133+
- `npm run destroyBackend`
135134
- Destroy the infrastructure stack with AWS CDK
136135
- `npm run destroyFrontend`
137136
- Destroy the frontend stack with AWS CDK

api/lambda/mutationGraph.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const handler: Handler = async (event) => {
2929
mimeType: "application/vnd.gremlin-v2.0+json",
3030
headers: headers,
3131
});
32-
c._client._connection.on("close", (code: number, message: string) => {
32+
c._client._connection.on("close", (code, message) => {
3333
console.info(`close - ${code} ${message}`);
3434
if (code == 1006) {
3535
console.error("Connection closed prematurely");

api/lambda/queryGraph.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const handler: Handler = async (event) => {
2727
mimeType: "application/vnd.gremlin-v2.0+json",
2828
headers: headers,
2929
});
30-
c._client._connection.on("close", (code: number, message: string) => {
30+
c._client._connection.on("close", (code, message) => {
3131
console.info(`close - ${code} ${message}`);
3232
if (code == 1006) {
3333
console.error("Connection closed prematurely");

bin/backend.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const env = {
2121
account: process.env.CDK_DEFAULT_ACCOUNT,
2222
region: deployConfig.region || process.env.CDK_DEFAULT_REGION,
2323
};
24-
const { buildApiWithCDK } = deployConfig;
2524
const neptuneNetwork = new NeptuneNetworkStack(
2625
app,
2726
`${appName}-NeptuneNetworkStack`,
@@ -38,7 +37,6 @@ const neptuneNetwork = new NeptuneNetworkStack(
3837
);
3938

4039
new ApiStack(app, `${appName}-ApiStack`, {
41-
buildApiWithCDK,
4240
cognito: {
4341
adminEmail: deployConfig.adminEmail,
4442
},
@@ -50,13 +48,11 @@ new ApiStack(app, `${appName}-ApiStack`, {
5048
env,
5149
});
5250

53-
if (buildApiWithCDK) {
54-
new WafCloudFrontStack(app, `${appName}-WafStack`, {
55-
allowedIps: [],
56-
wafParamName: deployConfig.wafParamName,
57-
env: {
58-
...env,
59-
region: "us-east-1",
60-
},
61-
});
62-
}
51+
new WafCloudFrontStack(app, `${appName}-WafStack`, {
52+
allowedIps: deployConfig.allowedIps,
53+
wafParamName: deployConfig.wafParamName,
54+
env: {
55+
...env,
56+
region: "us-east-1",
57+
},
58+
});

cdk.context.json

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,5 @@
88
"us-east-1f"
99
],
1010
"ssm:account=140767035512:parameterName=CognitoParams:region=us-east-1": "{\"userPoolId\":\"us-east-1_zsH279jhh\",\"userPoolClientId\":\"c9prf7il5it7ioq3dlvji5g2c\",\"identityPoolId\":\"us-east-1:0b44688d-c1ed-496e-8e9f-7b7ce9a721a2\"}",
11-
"ssm:account=140767035512:parameterName=GraphQl:region=us-east-1": "https://cxb7zk64e5axzo2sywj2xmly4a.appsync-api.us-east-1.amazonaws.com/graphql",
12-
"availability-zones:account=309749931644:region=us-east-1": [
13-
"us-east-1a",
14-
"us-east-1b",
15-
"us-east-1c",
16-
"us-east-1d",
17-
"us-east-1e",
18-
"us-east-1f"
19-
],
20-
"availability-zones:account=730335228068:region=us-east-1": [
21-
"us-east-1a",
22-
"us-east-1b",
23-
"us-east-1c",
24-
"us-east-1d",
25-
"us-east-1e",
26-
"us-east-1f"
27-
]
11+
"ssm:account=140767035512:parameterName=GraphQl:region=us-east-1": "https://cxb7zk64e5axzo2sywj2xmly4a.appsync-api.us-east-1.amazonaws.com/graphql"
2812
}

config.sample.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const stage = "dev";
55
const baseConfig = {
66
appName: "graphApp",
77
region: "us-east-1",
8-
buildApiWithCDK: true,
98
adminEmail: "[email protected]",
109
allowedIps: [],
1110
wafParamName: "graphAppWafWebACLID",

docs/config.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
These properties in details are as follows.
44

5-
| Property | Description | Type | Default value |
6-
| ----------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------ | ----------------------------------------------- |
7-
| appName | Application name for stack | string | `dev` |
8-
| region | Deployment AWS resouces the to region | string | `us-east-1` |
9-
| buildApiWithCDK | Deployment API resouces with AWS CDK. If set `false`, deploy only Lambda Function URL for bulk load. | boolean | `true` |
10-
| adminEmail | Send the temporary password to this email for signing graph application | string | `[email protected]` |
11-
| allowedIps | AWS WAF allowed this ips to access to the graph application. e.g.) [`"192.0.3.0/24"`] | string[] | `[]` |
12-
| wafParamName | The name of Paramater store in AWS Systems Manager which stores the web acl id of AWS WAF | string | `graphAppWafWebACLID` |
13-
| webBucketsRemovalPolicy | Removal policy for S3 buckets | `RemovalPolicy` | `RemovalPolicy.DESTROY` |
14-
| s3Uri | S3 URI of `vertex.csv` and `edge.csv` which you stored in. | { edge: string,vertex: string} | `{edge: "EDGE_S3_URI",vertex: "VERTEX_S3_URI"}` |
5+
| Property | Description | Type | Default value |
6+
| ----------------------- | ----------------------------------------------------------------------------------------- | ------------------------------ | ----------------------------------------------- |
7+
| appName | Application name for stack | string | `dev` |
8+
| region | Deployment AWS resouces the to region | string | `us-east-1` |
9+
| adminEmail | Send the temporary password to this email for signing graph application | string | `[email protected]` |
10+
| allowedIps | AWS WAF allowed this ips to access to the graph application. e.g.) [`"192.0.3.0/24"`] | string[] | `[]` |
11+
| wafParamName | The name of Paramater store in AWS Systems Manager which stores the web acl id of AWS WAF | string | `graphAppWafWebACLID` |
12+
| webBucketsRemovalPolicy | Removal policy for S3 buckets | `RemovalPolicy` | `RemovalPolicy.DESTROY` |
13+
| s3Uri | S3 URI of `vertex.csv` and `edge.csv` which you stored in. | { edge: string,vertex: string} | `{edge: "EDGE_S3_URI",vertex: "VERTEX_S3_URI"}` |

lib/api-stack.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { Api, S3Uri } from "./constructs/api";
77
import * as path from "path";
88

99
interface ApiStackProps extends StackProps {
10-
buildApiWithCDK: boolean;
1110
cognito: {
1211
adminEmail: string;
1312
userName?: string;
@@ -20,28 +19,18 @@ interface ApiStackProps extends StackProps {
2019
}
2120

2221
export class ApiStack extends Stack {
23-
public readonly cognito: Cognito | undefined;
22+
public readonly cognito: Cognito;
2423
public readonly graphqlUrl: string;
2524
constructor(scope: Construct, id: string, props: ApiStackProps) {
26-
const {
27-
buildApiWithCDK,
28-
cognito,
29-
vpc,
30-
cluster,
31-
clusterRole,
32-
graphqlFieldName,
33-
s3Uri,
34-
} = props;
25+
const { cognito, vpc, cluster, clusterRole, graphqlFieldName, s3Uri } =
26+
props;
3527
super(scope, id, props);
36-
this.cognito = buildApiWithCDK
37-
? new Cognito(this, "cognito", {
38-
adminEmail: cognito.adminEmail,
39-
userName: cognito.userName,
40-
refreshTokenValidity: Duration.days(1),
41-
})
42-
: undefined;
28+
this.cognito = new Cognito(this, "cognito", {
29+
adminEmail: cognito.adminEmail,
30+
userName: cognito.userName,
31+
refreshTokenValidity: Duration.days(1),
32+
});
4333
const api = new Api(this, "api", {
44-
buildApiWithCDK,
4534
schema: path.join(__dirname, "../api/graphql/schema.graphql"),
4635
vpc,
4736
cluster,

0 commit comments

Comments
 (0)