# DatabaseClusterAttributes

Properties that describe an existing cluster instance.

Used as argument in: [DatabaseCluster.fromDatabaseClusterAttributes](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rds.DatabaseCluster.html#fromdatabaseclusterattributes)

- Source: [`aws-rds/lib/cluster-ref.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-rds/lib/cluster-ref.ts#L84)
- Type last changed: v2.162.0 · 10 Oct 2024

## Example

TypeScript:

```ts
declare const vpc: ec2.Vpc;
declare const fn: lambda.Function;
declare const secret: secretsmanager.Secret;

// Create a serverless V1 cluster
const serverlessV1Cluster = new rds.ServerlessCluster(this, 'AnotherCluster', {
  engine: rds.DatabaseClusterEngine.AURORA_MYSQL,
  vpc, // this parameter is optional for serverless Clusters
  enableDataApi: true, // Optional - will be automatically set if you call grantDataApiAccess()
});
serverlessV1Cluster.grantDataApiAccess(fn);

// Create an Aurora cluster
const cluster = new rds.DatabaseCluster(this, 'Cluster', {
  engine: rds.DatabaseClusterEngine.AURORA_MYSQL,
  vpc,
  enableDataApi: true, // Optional - will be automatically set if you call grantDataApiAccess()
});
cluster.grantDataApiAccess(fn);

// Import an Aurora cluster
const importedCluster = rds.DatabaseCluster.fromDatabaseClusterAttributes(this, 'ImportedCluster', {
  clusterIdentifier: 'clusterIdentifier',
  secret,
  dataApiEnabled: true,
});
importedCluster.grantDataApiAccess(fn);
```

Python:

```python
# vpc: ec2.Vpc
# fn: lambda.Function
# secret: secretsmanager.Secret

# Create a serverless V1 cluster
serverless_v1_cluster = rds.ServerlessCluster(self, "AnotherCluster",
    engine=rds.DatabaseClusterEngine.AURORA_MYSQL,
    vpc=vpc,  # this parameter is optional for serverless Clusters
    enable_data_api=True
)
serverless_v1_cluster.grant_data_api_access(fn)

# Create an Aurora cluster
cluster = rds.DatabaseCluster(self, "Cluster",
    engine=rds.DatabaseClusterEngine.AURORA_MYSQL,
    vpc=vpc,
    enable_data_api=True
)
cluster.grant_data_api_access(fn)

# Import an Aurora cluster
imported_cluster = rds.DatabaseCluster.from_database_cluster_attributes(self, "ImportedCluster",
    cluster_identifier="clusterIdentifier",
    secret=secret,
    data_api_enabled=True
)
imported_cluster.grant_data_api_access(fn)
```

Java:

```java
Vpc vpc;
Function fn;
Secret secret;

// Create a serverless V1 cluster
ServerlessCluster serverlessV1Cluster = ServerlessCluster.Builder.create(this, "AnotherCluster")
        .engine(DatabaseClusterEngine.AURORA_MYSQL)
        .vpc(vpc) // this parameter is optional for serverless Clusters
        .enableDataApi(true)
        .build();
serverlessV1Cluster.grantDataApiAccess(fn);

// Create an Aurora cluster
DatabaseCluster cluster = DatabaseCluster.Builder.create(this, "Cluster")
        .engine(DatabaseClusterEngine.AURORA_MYSQL)
        .vpc(vpc)
        .enableDataApi(true)
        .build();
cluster.grantDataApiAccess(fn);

// Import an Aurora cluster
IDatabaseCluster importedCluster = DatabaseCluster.fromDatabaseClusterAttributes(this, "ImportedCluster", DatabaseClusterAttributes.builder()
        .clusterIdentifier("clusterIdentifier")
        .secret(secret)
        .dataApiEnabled(true)
        .build());
importedCluster.grantDataApiAccess(fn);
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Vpc vpc;
Function fn;
Secret secret;

// Create a serverless V1 cluster
var serverlessV1Cluster = new ServerlessCluster(this, "AnotherCluster", new ServerlessClusterProps {
    Engine = DatabaseClusterEngine.AURORA_MYSQL,
    Vpc = vpc,  // this parameter is optional for serverless Clusters
    EnableDataApi = true
});
serverlessV1Cluster.GrantDataApiAccess(fn);

// Create an Aurora cluster
var cluster = new DatabaseCluster(this, "Cluster", new DatabaseClusterProps {
    Engine = DatabaseClusterEngine.AURORA_MYSQL,
    Vpc = vpc,
    EnableDataApi = true
});
cluster.GrantDataApiAccess(fn);

// Import an Aurora cluster
var importedCluster = DatabaseCluster.FromDatabaseClusterAttributes(this, "ImportedCluster", new DatabaseClusterAttributes {
    ClusterIdentifier = "clusterIdentifier",
    Secret = secret,
    DataApiEnabled = true
});
importedCluster.GrantDataApiAccess(fn);
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var vpc Vpc
var fn Function
var secret Secret

// Create a serverless V1 cluster
serverlessV1Cluster := rds.NewServerlessCluster(this, jsii.String("AnotherCluster"), &ServerlessClusterProps{
	Engine: rds.DatabaseClusterEngine_AURORA_MYSQL(),
	Vpc: Vpc,
	 // this parameter is optional for serverless Clusters
	EnableDataApi: jsii.Boolean(true),
})
serverlessV1Cluster.grantDataApiAccess(fn)

// Create an Aurora cluster
cluster := rds.NewDatabaseCluster(this, jsii.String("Cluster"), &DatabaseClusterProps{
	Engine: rds.DatabaseClusterEngine_AURORA_MYSQL(),
	Vpc: Vpc,
	EnableDataApi: jsii.Boolean(true),
})
cluster.GrantDataApiAccess(fn)

// Import an Aurora cluster
importedCluster := rds.DatabaseCluster_FromDatabaseClusterAttributes(this, jsii.String("ImportedCluster"), &DatabaseClusterAttributes{
	ClusterIdentifier: jsii.String("clusterIdentifier"),
	Secret: Secret,
	DataApiEnabled: jsii.Boolean(true),
})
importedCluster.GrantDataApiAccess(fn)
```

## Properties

- `clusterEndpointAddress`: string — Cluster endpoint address.

  **Default:** no endpoint address

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

- `clusterResourceIdentifier`: string = none — The immutable identifier for the cluster; for example: cluster-ABCD1234EFGH5678IJKL90MNOP.

  This AWS Region-unique identifier is used to grant access to the cluster.

- `dataApiEnabled`: boolean = false — Whether the Data API for the cluster is enabled.

- `engine`: [IClusterEngine](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rds.IClusterEngine.html) — The engine of the existing Cluster.

  **Default:** the imported Cluster's engine is unknown

- `instanceEndpointAddresses`: string[] — Endpoint addresses of individual instances.

  **Default:** no instance endpoints

- `instanceIdentifiers`: string[] — Identifier for the instances.

  **Default:** no instance identifiers

- `port`: number = none — The database port.

- `readerEndpointAddress`: string — Reader endpoint address.

  **Default:** no reader address

- `secret`: [ISecret](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager.ISecret.html) — The secret attached to the database cluster.

  **Default:** the imported Cluster's secret is unknown

- `securityGroups`: [ISecurityGroup](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html)[] — The security groups of the database cluster.

  **Default:** no security groups
