Skip to content

Commit

Permalink
chore: Replace old POC for Neptune with the real deal (#848)
Browse files Browse the repository at this point in the history
The Neptune package that was provided so far was the result of a proof-of-concept that was made
before the eventual Neptune API was made available. Replacing this with the generated L1 for
Neptune, that would otherwise not have been available at all.

Fixes #807
  • Loading branch information
RomainMuller authored Oct 4, 2018
1 parent 3d1095e commit ed1e1e4
Show file tree
Hide file tree
Showing 9 changed files with 19,807 additions and 259 deletions.
21 changes: 0 additions & 21 deletions examples/cdk-examples-typescript/neptune-demo/cdk.json

This file was deleted.

33 changes: 0 additions & 33 deletions examples/cdk-examples-typescript/neptune-demo/index.ts

This file was deleted.

15 changes: 7 additions & 8 deletions packages/@aws-cdk/aws-neptune/.gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
*.d.ts
*.generated.ts
*.js
tsconfig.json
tslint.json
*.js.map
*.d.ts
dist
lib/generated/resources.ts
.jsii

.LAST_BUILD
.LAST_PACKAGE
.nycrc
.nyc_output
coverage
.nycrc
.LAST_PACKAGE
dist
tsconfig.json
tslint.json
16 changes: 9 additions & 7 deletions packages/@aws-cdk/aws-neptune/.npmignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Don't include original .ts files when doing `npm pack`
# The basics
*.ts
*.tgz
!*.d.ts
!*.js

# Coverage
coverage
.nyc_output
*.tgz
.nycrc

# Build gear
dist
.LAST_PACKAGE
.LAST_BUILD
!*.js

# Include .jsii
!.jsii
.LAST_PACKAGE
.jsii
7 changes: 5 additions & 2 deletions packages/@aws-cdk/aws-neptune/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
## CDK Constructs for AWS Neptune
This module is part of the [AWS Cloud Development Kit](https://github.com/awslabs/aws-cdk) project.
## AWS Neptune Construct Library

```ts
const neptune = require('@aws-cdk/aws-neptune');
```
144 changes: 2 additions & 142 deletions packages/@aws-cdk/aws-neptune/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,142 +1,2 @@
import ec2 = require('@aws-cdk/aws-ec2');
import rds = require('@aws-cdk/aws-rds');
import cdk = require('@aws-cdk/cdk');

/**
* Properties for a Neptune Graph Database Cluster
*/
export interface NeptuneDatabaseProps {
/**
* How many replicas/instances to create
*
* Has to be at least 1. Default is 2.
*
* @default 2
*/
instances?: number;

/**
* Settings for the individual instances that are launched
*/
instanceProps: rds.InstanceProps;

/**
* Username and password for the administrative user
*/
masterUser: rds.Login;

/**
* What port to listen on
*
* @default 3306
*/
port?: number;

/**
* An optional identifier for the cluster
*
* If not given, a name is generated.
*/
clusterIdentifier?: string;

/**
* Base identifier for instances
*
* Every replica is named by appending the replica number to this string, 1-based.
*
* If not given, the clusterIdentifier is used with the word "Instance" appended.
*
* If clusterIdentifier is also not given, the identifier is automatically generated.
*/
instanceIdentifierBase?: string;

/**
* Name of a database which is automatically created inside the cluster
*
* If not given, no database is created.
*/
defaultDatabaseName?: string;

/**
* ARN of KMS key if you want to enable storage encryption
*/
kmsKeyArn?: string;

/**
* A daily time range in 24-hours UTC format in which backups preferably execute.
*
* Must be at least 30 minutes long.
*
* Example: '01:00-02:00'
*
* If not given, an window is randomly.
*/
preferredMaintenanceWindow?: string;

/**
* Parameter group with Neptune settings
*
* @default No parameter group
*/
parameterGroup?: rds.ClusterParameterGroupRef;
}

/**
* Neptune Graph Database cluster
*
* Creates a new Neptune database cluster with a given number of replicas.
*/
export class NeptuneDatabase extends cdk.Construct implements ec2.IConnectable {
/**
* Identifier of the cluster
*/
public readonly clusterIdentifier: string;

/**
* Identifiers of the replicas
*/
public readonly instanceIdentifiers: string[] = [];

/**
* The endpoint to use for read/write operations
*/
public readonly clusterEndpoint: rds.Endpoint;

/**
* Endpoint to use for load-balanced read-only operations.
*/
public readonly readerEndpoint: rds.Endpoint;

/**
* Endpoints which address each individual replica.
*/
public readonly instanceEndpoints: rds.Endpoint[] = [];

public readonly connections: ec2.Connections;

private readonly cluster: rds.DatabaseCluster;

constructor(parent: cdk.Construct, name: string, props: NeptuneDatabaseProps) {
super(parent, name);

this.cluster = new rds.DatabaseCluster(this, 'Cluster', {
engine: rds.DatabaseClusterEngine.Aurora,
instances: props.instances,
instanceProps: props.instanceProps,
masterUser: props.masterUser,
port: props.port,
clusterIdentifier: props.clusterIdentifier,
instanceIdentifierBase: props.instanceIdentifierBase,
defaultDatabaseName: props.defaultDatabaseName,
kmsKeyArn: props.kmsKeyArn,
preferredMaintenanceWindow: props.preferredMaintenanceWindow,
parameterGroup: props.parameterGroup,
});

this.clusterIdentifier = this.cluster.clusterIdentifier;
this.instanceIdentifiers = this.cluster.instanceIdentifiers;
this.clusterEndpoint = this.cluster.clusterEndpoint;
this.readerEndpoint = this.cluster.readerEndpoint;
this.connections = this.cluster.connections;
}
}
// AWS::Neptune CloudFormation Resources:
export * from './neptune.generated';
Loading

0 comments on commit ed1e1e4

Please sign in to comment.