Skip to content
v2.273.0

Experimental

@aws-cdk/aws-neptune-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

DatabaseCluster L2 construct ​

Create a clustered database with a given number of instances.

Example ​

ts
const cluster = new neptune.DatabaseCluster(this, 'ServerlessDatabase', {
  vpc,
  instanceType: neptune.InstanceType.SERVERLESS,
  serverlessScalingConfiguration: {
    minCapacity: 1,
    maxCapacity: 5,
  },
});
python
cluster = neptune.DatabaseCluster(self, "ServerlessDatabase",
    vpc=vpc,
    instance_type=neptune.InstanceType.SERVERLESS,
    serverless_scaling_configuration=neptune.ServerlessScalingConfiguration(
        min_capacity=1,
        max_capacity=5
    )
)
java
DatabaseCluster cluster = DatabaseCluster.Builder.create(this, "ServerlessDatabase")
        .vpc(vpc)
        .instanceType(InstanceType.SERVERLESS)
        .serverlessScalingConfiguration(ServerlessScalingConfiguration.builder()
                .minCapacity(1)
                .maxCapacity(5)
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Neptune.Alpha
var cluster = new DatabaseCluster(this, "ServerlessDatabase", new DatabaseClusterProps {
    Vpc = vpc,
    InstanceType = InstanceType.SERVERLESS,
    ServerlessScalingConfiguration = new ServerlessScalingConfiguration {
        MinCapacity = 1,
        MaxCapacity = 5
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdkneptunealpha/v2
cluster := neptune.NewDatabaseCluster(this, jsii.String("ServerlessDatabase"), &DatabaseClusterProps{
	Vpc: Vpc,
	InstanceType: neptune.InstanceType_SERVERLESS(),
	ServerlessScalingConfiguration: &ServerlessScalingConfiguration{
		MinCapacity: jsii.Number(1),
		MaxCapacity: jsii.Number(5),
	},
})

Initializer ​

ts
new DatabaseCluster(scope: Construct, id: string, props: DatabaseClusterProps)
python
DatabaseCluster(scope: Construct, id: str, props: DatabaseClusterProps)
java
new DatabaseCluster(Construct scope, String id, DatabaseClusterProps props)
csharp
new DatabaseCluster(Construct scope, string id, DatabaseClusterProps props)
go
NewDatabaseCluster(Scope Construct, Id *string, Props DatabaseClusterProps)

Construct Props ​

associatedRolesIRole[]associated_rolestyping.List[IRole]associatedRolesList<IRole>AssociatedRolesIRole[]AssociatedRoles*[]IRole= No role is attached to the clust…#
A list of AWS Identity and Access Management (IAM) role that can be used by the cluster to access other AWS services.
default

Default: No role is attached to the cluster.

autoMinorVersionUpgradebooleanauto_minor_version_upgradeboolautoMinorVersionUpgradeBooleanAutoMinorVersionUpgradeboolAutoMinorVersionUpgrade*bool= 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.
backupRetentionDurationbackup_retentionDurationbackupRetentionDurationBackupRetentionDurationBackupRetentionDuration= cdk.Duration.days(1)#
How many days to retain the backup.
cloudwatchLogsExportsLogType[]cloudwatch_logs_exportstyping.List[LogType]cloudwatchLogsExportsList<LogType>CloudwatchLogsExportsLogType[]CloudwatchLogsExports*[]LogType= no log exports#
The list of log types that need to be enabled for exporting to CloudWatch Logs.
cloudwatchLogsRetentionRetentionDayscloudwatch_logs_retentionRetentionDayscloudwatchLogsRetentionRetentionDaysCloudwatchLogsRetentionRetentionDaysCloudwatchLogsRetentionRetentionDays= logs never expire#
The number of days log events are kept in CloudWatch Logs.

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

cloudwatchLogsRetentionRoleIRolecloudwatch_logs_retention_roleIRolecloudwatchLogsRetentionRoleIRoleCloudwatchLogsRetentionRoleIRoleCloudwatchLogsRetentionRoleIRole= a new role is created.#
The IAM role for the Lambda function associated with the custom resource that sets the retention policy.
clusterParameterGroupIClusterParameterGroupcluster_parameter_groupIClusterParameterGroupclusterParameterGroupIClusterParameterGroupClusterParameterGroupIClusterParameterGroupClusterParameterGroupIClusterParameterGroup= No parameter group.#
Additional parameters to pass to the database engine.
copyTagsToSnapshotbooleancopy_tags_to_snapshotboolcopyTagsToSnapshotBooleanCopyTagsToSnapshotboolCopyTagsToSnapshot*bool= false#
Whether to copy tags to the snapshot when a snapshot is created.
dbClusterNamestringdb_cluster_namestrdbClusterNameStringDbClusterNamestringDbClusterName*string= A name is automatically generate…#
An optional identifier for the cluster.
default

Default: A name is automatically generated.

deletionProtectionbooleandeletion_protectionbooldeletionProtectionBooleanDeletionProtectionboolDeletionProtection*bool= true if ``removalPolicy`` is RET…#
Indicates whether the DB cluster should have deletion protection enabled.
default

Default: true if removalPolicy is RETAIN, false otherwise

engineVersionEngineVersionengine_versionEngineVersionengineVersionEngineVersionEngineVersionEngineVersionEngineVersionEngineVersion= The default engine version.#
What version of the database to start.
iamAuthenticationbooleaniam_authenticationbooliamAuthenticationBooleanIamAuthenticationboolIamAuthentication*bool= `false`#
Map AWS Identity and Access Management (IAM) accounts to database accounts.
instanceIdentifierBasestringinstance_identifier_basestrinstanceIdentifierBaseStringInstanceIdentifierBasestringInstanceIdentifierBase*string= `dbClusterName` is used with the…#
Base identifier for instances.

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

default

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

instancesnumberinstancesint | floatinstancesNumberInstancesdoubleInstances*float64= 1#
Number of Neptune compute instances.
instanceTypeInstanceTypeinstance_typeInstanceTypeinstanceTypeInstanceTypeInstanceTypeInstanceTypeInstanceTypeInstanceTyperequired#
What type of instance to start for the replicas.
kmsKeyIKeyRefkms_keyIKeyRefkmsKeyIKeyRefKmsKeyIKeyRefKmsKeyIKeyRef= default master key.#
The KMS key for storage encryption.
parameterGroupIParameterGroupparameter_groupIParameterGroupparameterGroupIParameterGroupParameterGroupIParameterGroupParameterGroupIParameterGroup= no parameter group#
The DB parameter group to associate with the instance.
portnumberportint | floatportNumberPortdoublePort*float64= 8182#
The port number on which the DB instances in the DB cluster accept connections.
preferredBackupWindowstringpreferred_backup_windowstrpreferredBackupWindowStringPreferredBackupWindowstringPreferredBackupWindow*string= a 30-minute window selected at r…#
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'

default

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

preferredMaintenanceWindowstringpreferred_maintenance_windowstrpreferredMaintenanceWindowStringPreferredMaintenanceWindowstringPreferredMaintenanceWindow*string= 30-minute window selected at ran…#
A weekly time range in which maintenance should preferably execute.

Must be at least 30 minutes long.

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

default

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.

removalPolicyRemovalPolicyremoval_policyRemovalPolicyremovalPolicyRemovalPolicyRemovalPolicyRemovalPolicyRemovalPolicyRemovalPolicy= Retain cluster.#
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.

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

securityGroupsISecurityGroup[]security_groupstyping.List[ISecurityGroup]securityGroupsList<ISecurityGroup>SecurityGroupsISecurityGroup[]SecurityGroups*[]ISecurityGroup= a new security group is created.#
Security group.
serverlessScalingConfigurationServerlessScalingConfigurationserverless_scaling_configurationServerlessScalingConfigurationserverlessScalingConfigurationServerlessScalingConfigurationServerlessScalingConfigurationServerlessScalingConfigurationServerlessScalingConfigurationServerlessScalingConfiguration= required if instanceType is db.s…#
Specify minimum and maximum NCUs capacity for a serverless cluster.
default

Default: required if instanceType is db.serverless

storageEncryptedbooleanstorage_encryptedboolstorageEncryptedBooleanStorageEncryptedboolStorageEncrypted*bool= true#
Whether to enable storage encryption.
subnetGroupISubnetGroupsubnet_groupISubnetGroupsubnetGroupISubnetGroupSubnetGroupISubnetGroupSubnetGroupISubnetGroup= a new subnet group will be creat…#
Existing subnet group for the cluster.
default

Default: a new subnet group will be created.

vpcIVpcvpcIVpcvpcIVpcVpcIVpcVpcIVpcrequired#
What subnets to run the Neptune instances in.

Must be at least 2 subnets in two different AZs.

vpcSubnetsSubnetSelectionvpc_subnetsSubnetSelectionvpcSubnetsSubnetSelectionVpcSubnetsSubnetSelectionVpcSubnetsSubnetSelection= private subnets#
Where to place the instances within the VPC.

Properties ​

clusterEndpointEndpointcluster_endpointEndpointclusterEndpointEndpointClusterEndpointEndpointClusterEndpointEndpointrequired#
The endpoint to use for read/write operations.
clusterIdentifierstringcluster_identifierstrclusterIdentifierStringClusterIdentifierstringClusterIdentifier*stringrequired#
Identifier of the cluster.
clusterReadEndpointEndpointcluster_read_endpointEndpointclusterReadEndpointEndpointClusterReadEndpointEndpointClusterReadEndpointEndpointrequired#
Endpoint to use for load-balanced read-only operations.
clusterResourceIdentifierstringcluster_resource_identifierstrclusterResourceIdentifierStringClusterResourceIdentifierstringClusterResourceIdentifier*stringrequired#
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.

connectionsConnectionsconnectionsConnectionsconnectionsConnectionsConnectionsConnectionsConnectionsConnectionsrequired#
The connections object to implement IConnectable.
DEFAULT_NUM_INSTANCESnumberdefault_num_instancesint | floatDEFAULT_NUM_INSTANCESNumberDEFAULT_NUM_INSTANCESdoubleDEFAULT_NUM_INSTANCES*float64requiredstatic#
The default number of instances in the Neptune cluster if none are specified.
The environment this resource belongs to.
notes

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.

instanceEndpointsEndpoint[]instance_endpointstyping.List[Endpoint]instanceEndpointsList<Endpoint>InstanceEndpointsEndpoint[]InstanceEndpoints*[]Endpointrequired#
Endpoints which address each individual instance.
instanceIdentifiersstring[]instance_identifierstyping.List[str]instanceIdentifiersList<String>InstanceIdentifiersstring[]InstanceIdentifiers*[]*stringrequired#
Identifiers of the instance.
nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.
subnetGroupISubnetGroupsubnet_groupISubnetGroupsubnetGroupISubnetGroupSubnetGroupISubnetGroupSubnetGroupISubnetGrouprequired#
Subnet group used by the DB.
vpcIVpcvpcIVpcvpcIVpcVpcIVpcVpcIVpcrequired#
The VPC where the DB subnet group is created.
vpcSubnetsSubnetSelectionvpc_subnetsSubnetSelectionvpcSubnetsSubnetSelectionVpcSubnetsSubnetSelectionVpcSubnetsSubnetSelectionrequired#
The subnets used by the DB subnet group.

Methods ​

applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

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

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

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@staticmethod def from_database_cluster_attributes(scope: Construct, id: str, attrs: DatabaseClusterAttributes) -> IDatabaseClusterpublic static IDatabaseCluster fromDatabaseClusterAttributes(Construct scope, String id, DatabaseClusterAttributes attrs)public static IDatabaseCluster FromDatabaseClusterAttributes(Construct scope, string id, DatabaseClusterAttributes attrs)func FromDatabaseClusterAttributes(Scope Construct, Id *string, Attrs DatabaseClusterAttributes) IDatabaseClusterstatic#
Import an existing DatabaseCluster from properties.
grant(grantee: IGrantable, ...actions: string[]): Grantdef grant(self, grantee: IGrantable, actions: str) -> Grantpublic Grant grant(IGrantable grantee, String actions)public Grant Grant(IGrantable grantee, string actions)func Grant(Grantee IGrantable, Actions *string) Grant#
[disable-awslint:no-grants].
grantConnect(grantee: IGrantable): Grantdef grant_connect(self, grantee: IGrantable) -> Grantpublic Grant grantConnect(IGrantable grantee)public Grant GrantConnect(IGrantable grantee)func GrantConnect(Grantee IGrantable) Grant#
[disable-awslint:no-grants].
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

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

  • xxxxX — Any object.

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

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
metric(metricName: string, props?: MetricOptions): Metricdef metric(self, metric_name: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metric(String metricName, MetricOptions props)public Metric Metric(string metricName, MetricOptions? props = null)func Metric(MetricName *string, Props MetricOptions) Metric#
Return the given named metric associated with this DatabaseCluster instance.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func 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.