|
1 |
| -import ec2 = require('@aws-cdk/aws-ec2'); |
2 |
| -import rds = require('@aws-cdk/aws-rds'); |
3 |
| -import cdk = require('@aws-cdk/cdk'); |
4 |
| - |
5 |
| -/** |
6 |
| - * Properties for a Neptune Graph Database Cluster |
7 |
| - */ |
8 |
| -export interface NeptuneDatabaseProps { |
9 |
| - /** |
10 |
| - * How many replicas/instances to create |
11 |
| - * |
12 |
| - * Has to be at least 1. Default is 2. |
13 |
| - * |
14 |
| - * @default 2 |
15 |
| - */ |
16 |
| - instances?: number; |
17 |
| - |
18 |
| - /** |
19 |
| - * Settings for the individual instances that are launched |
20 |
| - */ |
21 |
| - instanceProps: rds.InstanceProps; |
22 |
| - |
23 |
| - /** |
24 |
| - * Username and password for the administrative user |
25 |
| - */ |
26 |
| - masterUser: rds.Login; |
27 |
| - |
28 |
| - /** |
29 |
| - * What port to listen on |
30 |
| - * |
31 |
| - * @default 3306 |
32 |
| - */ |
33 |
| - port?: number; |
34 |
| - |
35 |
| - /** |
36 |
| - * An optional identifier for the cluster |
37 |
| - * |
38 |
| - * If not given, a name is generated. |
39 |
| - */ |
40 |
| - clusterIdentifier?: string; |
41 |
| - |
42 |
| - /** |
43 |
| - * Base identifier for instances |
44 |
| - * |
45 |
| - * Every replica is named by appending the replica number to this string, 1-based. |
46 |
| - * |
47 |
| - * If not given, the clusterIdentifier is used with the word "Instance" appended. |
48 |
| - * |
49 |
| - * If clusterIdentifier is also not given, the identifier is automatically generated. |
50 |
| - */ |
51 |
| - instanceIdentifierBase?: string; |
52 |
| - |
53 |
| - /** |
54 |
| - * Name of a database which is automatically created inside the cluster |
55 |
| - * |
56 |
| - * If not given, no database is created. |
57 |
| - */ |
58 |
| - defaultDatabaseName?: string; |
59 |
| - |
60 |
| - /** |
61 |
| - * ARN of KMS key if you want to enable storage encryption |
62 |
| - */ |
63 |
| - kmsKeyArn?: string; |
64 |
| - |
65 |
| - /** |
66 |
| - * A daily time range in 24-hours UTC format in which backups preferably execute. |
67 |
| - * |
68 |
| - * Must be at least 30 minutes long. |
69 |
| - * |
70 |
| - * Example: '01:00-02:00' |
71 |
| - * |
72 |
| - * If not given, an window is randomly. |
73 |
| - */ |
74 |
| - preferredMaintenanceWindow?: string; |
75 |
| - |
76 |
| - /** |
77 |
| - * Parameter group with Neptune settings |
78 |
| - * |
79 |
| - * @default No parameter group |
80 |
| - */ |
81 |
| - parameterGroup?: rds.ClusterParameterGroupRef; |
82 |
| -} |
83 |
| - |
84 |
| -/** |
85 |
| - * Neptune Graph Database cluster |
86 |
| - * |
87 |
| - * Creates a new Neptune database cluster with a given number of replicas. |
88 |
| - */ |
89 |
| -export class NeptuneDatabase extends cdk.Construct implements ec2.IConnectable { |
90 |
| - /** |
91 |
| - * Identifier of the cluster |
92 |
| - */ |
93 |
| - public readonly clusterIdentifier: string; |
94 |
| - |
95 |
| - /** |
96 |
| - * Identifiers of the replicas |
97 |
| - */ |
98 |
| - public readonly instanceIdentifiers: string[] = []; |
99 |
| - |
100 |
| - /** |
101 |
| - * The endpoint to use for read/write operations |
102 |
| - */ |
103 |
| - public readonly clusterEndpoint: rds.Endpoint; |
104 |
| - |
105 |
| - /** |
106 |
| - * Endpoint to use for load-balanced read-only operations. |
107 |
| - */ |
108 |
| - public readonly readerEndpoint: rds.Endpoint; |
109 |
| - |
110 |
| - /** |
111 |
| - * Endpoints which address each individual replica. |
112 |
| - */ |
113 |
| - public readonly instanceEndpoints: rds.Endpoint[] = []; |
114 |
| - |
115 |
| - public readonly connections: ec2.Connections; |
116 |
| - |
117 |
| - private readonly cluster: rds.DatabaseCluster; |
118 |
| - |
119 |
| - constructor(parent: cdk.Construct, name: string, props: NeptuneDatabaseProps) { |
120 |
| - super(parent, name); |
121 |
| - |
122 |
| - this.cluster = new rds.DatabaseCluster(this, 'Cluster', { |
123 |
| - engine: rds.DatabaseClusterEngine.Aurora, |
124 |
| - instances: props.instances, |
125 |
| - instanceProps: props.instanceProps, |
126 |
| - masterUser: props.masterUser, |
127 |
| - port: props.port, |
128 |
| - clusterIdentifier: props.clusterIdentifier, |
129 |
| - instanceIdentifierBase: props.instanceIdentifierBase, |
130 |
| - defaultDatabaseName: props.defaultDatabaseName, |
131 |
| - kmsKeyArn: props.kmsKeyArn, |
132 |
| - preferredMaintenanceWindow: props.preferredMaintenanceWindow, |
133 |
| - parameterGroup: props.parameterGroup, |
134 |
| - }); |
135 |
| - |
136 |
| - this.clusterIdentifier = this.cluster.clusterIdentifier; |
137 |
| - this.instanceIdentifiers = this.cluster.instanceIdentifiers; |
138 |
| - this.clusterEndpoint = this.cluster.clusterEndpoint; |
139 |
| - this.readerEndpoint = this.cluster.readerEndpoint; |
140 |
| - this.connections = this.cluster.connections; |
141 |
| - } |
142 |
| -} |
| 1 | +// AWS::Neptune CloudFormation Resources: |
| 2 | +export * from './neptune.generated'; |
0 commit comments