> **Experimental**
>
> `@aws-cdk/aws-neptune-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# DatabaseCluster

Create a clustered database with a given number of instances.

Extends: Construct › Resource › DatabaseClusterBase › DatabaseCluster
Implements: IDatabaseCluster, IResource, IConnectable, IEnvironmentAware, IConstruct, IDependable

- Stability: [Experimental](/cdk/api/stability.html)
- CloudFormation: [`AWS::Neptune::DBCluster`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-neptune-dbcluster.html)
- L1 type: [`CfnDBCluster`](/cdk/api/v2/docs/aws-cdk-lib.aws_neptune.CfnDBCluster.html)
- Source: [`lib/cluster.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0-alpha.0/packages/@aws-cdk/aws-neptune-alpha/lib/cluster.ts#L593)

## Example

```ts
const cluster = new neptune.DatabaseCluster(this, 'ServerlessDatabase', {
  vpc,
  instanceType: neptune.InstanceType.SERVERLESS,
  serverlessScalingConfiguration: {
    minCapacity: 1,
    maxCapacity: 5,
  },
});
```

## Initializer

```ts
new DatabaseCluster(scope: Construct, id: string, props: DatabaseClusterProps)
```

## Construct Props

- `associatedRoles`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html)[] — A list of AWS Identity and Access Management (IAM) role that can be used by the cluster to access other AWS services.

  **Default:** No role is attached to the cluster.

- `autoMinorVersionUpgrade`: boolean = false — If set to true, Neptune will automatically update the engine of the entire cluster to the latest minor version after a stabilization window of 2 to 3 weeks.

- `backupRetention`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = cdk.Duration.days(1) — How many days to retain the backup.

- `cloudwatchLogsExports`: [LogType](/cdk/api/v2/docs/@aws-cdk_aws-neptune-alpha.LogType.html)[] — The list of log types that need to be enabled for exporting to CloudWatch Logs.

  **Default:** no log exports

- `cloudwatchLogsRetention`: [RetentionDays](/cdk/api/v2/docs/aws-cdk-lib.aws_logs.RetentionDays.html) — The number of days log events are kept in CloudWatch Logs.

  **Default:** logs never expire

  When updating
  this property, unsetting it doesn't remove the log retention policy. To
  remove the retention policy, set the value to `Infinity`.

- `cloudwatchLogsRetentionRole`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The IAM role for the Lambda function associated with the custom resource that sets the retention policy.

  **Default:** a new role is created.

- `clusterParameterGroup`: [IClusterParameterGroup](/cdk/api/v2/docs/@aws-cdk_aws-neptune-alpha.IClusterParameterGroup.html) — Additional parameters to pass to the database engine.

  **Default:** No parameter group.

- `copyTagsToSnapshot`: boolean = false — Whether to copy tags to the snapshot when a snapshot is created.

- `dbClusterName`: string — An optional identifier for the cluster.

  **Default:** A name is automatically generated.

- `deletionProtection`: boolean — Indicates whether the DB cluster should have deletion protection enabled.

  **Default:** true if ``removalPolicy`` is RETAIN, false otherwise

- `engineVersion`: [EngineVersion](/cdk/api/v2/docs/@aws-cdk_aws-neptune-alpha.EngineVersion.html) — What version of the database to start.

  **Default:** The default engine version.

- `iamAuthentication`: boolean = `false` — Map AWS Identity and Access Management (IAM) accounts to database accounts.

- `instanceIdentifierBase`: string — Base identifier for instances.

  **Default:** `dbClusterName` is used with the word "Instance" appended. If `dbClusterName` is not provided, the identifier is automatically generated.

  Every replica is named by appending the replica number to this string, 1-based.

- `instances`: number = 1 — Number of Neptune compute instances.

- `instanceType`: [InstanceType](/cdk/api/v2/docs/@aws-cdk_aws-neptune-alpha.InstanceType.html) (required) — What type of instance to start for the replicas.

- `kmsKey`: [IKeyRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_kms.IKeyRef.html) — The KMS key for storage encryption.

  **Default:** default master key.

- `parameterGroup`: [IParameterGroup](/cdk/api/v2/docs/@aws-cdk_aws-neptune-alpha.IParameterGroup.html) — The DB parameter group to associate with the instance.

  **Default:** no parameter group

- `port`: number = 8182 — The port number on which the DB instances in the DB cluster accept connections.

- `preferredBackupWindow`: string — A daily time range in 24-hours UTC format in which backups preferably execute.

  **Default:** a 30-minute window selected at random from an 8-hour block of time for each AWS Region. To see the time blocks available, see

  Must be at least 30 minutes long.

  Example: '01:00-02:00'

- `preferredMaintenanceWindow`: string — A weekly time range in which maintenance should preferably execute.

  **Default:** 30-minute window selected at random from an 8-hour block of time for each AWS Region, occurring on a random day of the week.

  Must be at least 30 minutes long.

  Example: 'tue:04:17-tue:04:47'

- `removalPolicy`: [RemovalPolicy](/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) — The removal policy to apply when the cluster and its instances are removed or replaced during a stack update, or when the stack is deleted.

  **Default:** Retain cluster.

  This
  removal policy also applies to the implicit security group created for the
  cluster if one is not supplied as a parameter.

- `securityGroups`: [ISecurityGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html)[] — Security group.

  **Default:** a new security group is created.

- `serverlessScalingConfiguration`: [ServerlessScalingConfiguration](/cdk/api/v2/docs/@aws-cdk_aws-neptune-alpha.ServerlessScalingConfiguration.html) — Specify minimum and maximum NCUs capacity for a serverless cluster.

  **Default:** required if instanceType is db.serverless

  See https://docs.aws.amazon.com/neptune/latest/userguide/neptune-serverless-capacity-scaling.html

- `storageEncrypted`: boolean = true — Whether to enable storage encryption.

- `subnetGroup`: [ISubnetGroup](/cdk/api/v2/docs/@aws-cdk_aws-neptune-alpha.ISubnetGroup.html) — Existing subnet group for the cluster.

  **Default:** a new subnet group will be created.

- `vpc`: [IVpc](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) (required) — What subnets to run the Neptune instances in.

  Must be at least 2 subnets in two different AZs.

- `vpcSubnets`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) — Where to place the instances within the VPC.

  **Default:** private subnets

## Properties

- `clusterEndpoint`: [Endpoint](/cdk/api/v2/docs/@aws-cdk_aws-neptune-alpha.Endpoint.html) (required) — The endpoint to use for read/write operations.

- `clusterIdentifier`: string (required) — Identifier of the cluster.

- `clusterReadEndpoint`: [Endpoint](/cdk/api/v2/docs/@aws-cdk_aws-neptune-alpha.Endpoint.html) (required) — Endpoint to use for load-balanced read-only operations.

- `clusterResourceIdentifier`: string (required) — The resource id for the cluster;

  for example: cluster-ABCD1234EFGH5678IJKL90MNOP. The cluster ID uniquely
  identifies the cluster and is used in things like IAM authentication policies.

- `connections`: [Connections](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) (required) — The connections object to implement IConnectable.

- `DEFAULT_NUM_INSTANCES`: number (required) (static) — The default number of instances in the Neptune cluster if none are specified.

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) (required) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `instanceEndpoints`: [Endpoint](/cdk/api/v2/docs/@aws-cdk_aws-neptune-alpha.Endpoint.html)[] (required) — Endpoints which address each individual instance.

- `instanceIdentifiers`: string[] (required) — Identifiers of the instance.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) (required) — The tree node.

- `PROPERTY_INJECTION_ID`: string (required) (static) — Uniquely identifies this class.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) (required) — The stack in which this resource is defined.

- `subnetGroup`: [ISubnetGroup](/cdk/api/v2/docs/@aws-cdk_aws-neptune-alpha.ISubnetGroup.html) (required) — Subnet group used by the DB.

- `vpc`: [IVpc](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) (required) — The VPC where the DB subnet group is created.

- `vpcSubnets`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) (required) — The subnets used by the DB subnet group.

## Methods

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `fromDatabaseClusterAttributes(scope: Construct, id: string, attrs: DatabaseClusterAttributes): IDatabaseCluster` (static) — Import an existing DatabaseCluster from properties.

- `grant(grantee: IGrantable, ...actions: string[]): Grant` — [disable-awslint:no-grants].

- `grantConnect(grantee: IGrantable): Grant` — [disable-awslint:no-grants].

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `metric(metricName: string, props?: MetricOptions): Metric` — Return the given named metric associated with this DatabaseCluster instance.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
