# Amazon Aurora DSQL Construct Library

> Version 2.278.0-alpha.0

> **Separate package**
>
> `@aws-cdk/aws-dsql-alpha` is not part of `aws-cdk-lib` — install it separately:
>
> ```sh
> npm install @aws-cdk/aws-dsql-alpha
> pip install aws-cdk.aws-dsql-alpha
> ```
>
> This module is [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha): its API may change in any release, without a major version bump.
---

![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)

> The APIs of higher level constructs in this module are experimental and under active development.
> They are subject to non-backward compatible changes or removal in any future version. These are
> not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
> announced in the release notes. This means that while you may use them, you may need to update
> your source code when upgrading to a newer version of this package.

---

Amazon Aurora DSQL is a serverless, distributed relational database service optimized for transactional workloads. Aurora DSQL offers virtually unlimited scale and doesn't require you to manage infrastructure. The active-active highly available architecture provides 99.99% single-Region and 99.999% multi-Region availability.

The `@aws-cdk/aws-dsql-alpha` package contains primitives for setting up Aurora DSQL clusters.

TypeScript:

```ts
import * as dsql from '@aws-cdk/aws-dsql-alpha';
```

Python:

```python
import aws_cdk.aws_dsql_alpha as dsql
```

Java:

```java
import software.amazon.awscdk.services.dsql.alpha.*;
```

C# / .NET:

```csharp
using Amazon.CDK.AWS.DSQL.Alpha;
```

Golang:

```go
import dsql "github.com/aws/aws-cdk-go/awscdkdsqlalpha"
```

## Creating an Aurora DSQL Cluster

To create an Aurora DSQL cluster, define a [`Cluster`](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-dsql-alpha.Cluster.html):

TypeScript:

```ts
const cluster = new dsql.Cluster(this, 'Cluster', {
  clusterName: 'my-dsql-cluster',
  deletionProtection: true,
});
```

Python:

```python
cluster = dsql.Cluster(self, "Cluster",
    cluster_name="my-dsql-cluster",
    deletion_protection=True
)
```

Java:

```java
Cluster cluster = Cluster.Builder.create(this, "Cluster")
        .clusterName("my-dsql-cluster")
        .deletionProtection(true)
        .build();
```

C# / .NET:

```csharp
var cluster = new Cluster(this, "Cluster", new ClusterProps {
    ClusterName = "my-dsql-cluster",
    DeletionProtection = true
});
```

Golang:

```go
cluster := dsql.NewCluster(this, jsii.String("Cluster"), &ClusterProps{
	ClusterName: jsii.String("my-dsql-cluster"),
	DeletionProtection: jsii.Boolean(true),
})
```

## Granting Connect Access

You can grant IAM principals the ability to connect to the cluster:

TypeScript:

```ts
const role = new iam.Role(this, 'DBRole', { assumedBy: new iam.AccountPrincipal(this.account) });
const cluster = new dsql.Cluster(this, 'Cluster');

// Use one of the following statements to grant the role the necessary permissions
cluster.grantConnect(role); // Grant the role dsql:DbConnect
cluster.grantConnectAdmin(role); // Grant the role dsql:DbConnectAdmin
cluster.grant(role, 'dsql:DbConnect'); // Grant the role the specified actions to the cluster
```

Python:

```python
role = iam.Role(self, "DBRole", assumed_by=iam.AccountPrincipal(self.account))
cluster = dsql.Cluster(self, "Cluster")

# Use one of the following statements to grant the role the necessary permissions
cluster.grant_connect(role) # Grant the role dsql:DbConnect
cluster.grant_connect_admin(role) # Grant the role dsql:DbConnectAdmin
cluster.grant(role, "dsql:DbConnect")
```

Java:

```java
Role role = Role.Builder.create(this, "DBRole").assumedBy(new AccountPrincipal(this.account)).build();
Cluster cluster = new Cluster(this, "Cluster");

// Use one of the following statements to grant the role the necessary permissions
cluster.grantConnect(role); // Grant the role dsql:DbConnect
cluster.grantConnectAdmin(role); // Grant the role dsql:DbConnectAdmin
cluster.grant(role, "dsql:DbConnect");
```

C# / .NET:

```csharp
var role = new Role(this, "DBRole", new RoleProps { AssumedBy = new AccountPrincipal(Account) });
var cluster = new Cluster(this, "Cluster");

// Use one of the following statements to grant the role the necessary permissions
cluster.GrantConnect(role); // Grant the role dsql:DbConnect
cluster.GrantConnectAdmin(role); // Grant the role dsql:DbConnectAdmin
cluster.Grant(role, "dsql:DbConnect");
```

Golang:

```go
role := iam.NewRole(this, jsii.String("DBRole"), &RoleProps{
	AssumedBy: iam.NewAccountPrincipal(this.Account),
})
cluster := dsql.NewCluster(this, jsii.String("Cluster"))

// Use one of the following statements to grant the role the necessary permissions
cluster.grantConnect(role) // Grant the role dsql:DbConnect
cluster.grantConnectAdmin(role) // Grant the role dsql:DbConnectAdmin
cluster.grant(role, jsii.String("dsql:DbConnect"))
```

## Types

### Constructs (L2)

- [`Cluster`](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-dsql-alpha.Cluster.html) Construct (L2) Create an Aurora DSQL cluster.

### Structs

- [`ClusterAttributes`](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-dsql-alpha.ClusterAttributes.html) Struct Properties that describe an existing Aurora DSQL cluster.
- [`ClusterProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-dsql-alpha.ClusterProps.html) Struct Properties for a new Aurora DSQL cluster.

### Interfaces

- [`ICluster`](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-dsql-alpha.ICluster.html) Interface Represents an Aurora DSQL cluster.
