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

Create a Redshift cluster a given number of nodes.

Extends: Construct › Resource › Cluster
Implements: ICluster, IResource, IConnectable, ISecretAttachmentTarget, IEnvironmentAware, IConstruct, IDependable

- Stability: [Experimental](/cdk/api/stability.html)
- CloudFormation: [`AWS::Redshift::Cluster`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-redshift-cluster.html)
- L1 type: [`CfnCluster`](/cdk/api/v2/docs/aws-cdk-lib.aws_redshift.CfnCluster.html)
- Source: [`lib/cluster.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0-alpha.0/packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts#L648)

## Example

```ts
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as iam from 'aws-cdk-lib/aws-iam';
declare const vpc: ec2.Vpc;

const defaultRole = new iam.Role(this, 'DefaultRole', {
  assumedBy: new iam.ServicePrincipal('redshift.amazonaws.com'),
},
);

new Cluster(this, 'Redshift', {
    masterUser: {
      masterUsername: 'admin',
    },
    vpc,
    roles: [defaultRole],
    defaultRole: defaultRole,
});
```

## Initializer

```ts
new Cluster(scope: Construct, id: string, props: ClusterProps)
```

## Construct Props

- `availabilityZoneRelocation`: boolean = false — Whether to enable relocation for an Amazon Redshift cluster between Availability Zones after the cluster is created.

- `classicResizing`: boolean — If this flag is set, the cluster resizing type will be set to classic.

  **Default:** Elastic resize type

  When resizing a cluster, classic resizing will always provision a new cluster and transfer the data there.

  Classic resize takes more time to complete, but it can be useful in cases where the change in node count or
  the node type to migrate to doesn't fall within the bounds for elastic resize.

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

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

- `clusterType`: [ClusterType](/cdk/api/v2/docs/@aws-cdk_aws-redshift-alpha.ClusterType.html) = `ClusterType.MULTI_NODE` — Settings for the individual instances that are launched.

- `defaultDatabaseName`: string = default_db — Name of a database which is automatically created inside the cluster.

- `defaultRole`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — A single AWS Identity and Access Management (IAM) role to be used as the default role for the cluster.

  **Default:** No default role is specified for the cluster.

  The default role must be included in the roles list.

- `elasticIp`: string — The Elastic IP (EIP) address for the cluster.

  **Default:** No Elastic IP

- `encrypted`: boolean = true — Whether to enable encryption of data at rest in the cluster.

- `encryptionKey`: [IKeyRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_kms.IKeyRef.html) — The KMS key to use for encryption of data at rest.

  **Default:** AWS-managed key, if encryption at rest is enabled

- `enhancedVpcRouting`: boolean = false — If this flag is set, Amazon Redshift forces all COPY and UNLOAD traffic between your cluster and your data repositories through your virtual private cloud (VPC).

- `logging`: [ClusterLogging](/cdk/api/v2/docs/@aws-cdk_aws-redshift-alpha.ClusterLogging.html) — Logging configuration for the cluster.

  **Default:** no logging

- `maintenanceTrackName`: [MaintenanceTrackName](/cdk/api/v2/docs/@aws-cdk_aws-redshift-alpha.MaintenanceTrackName.html) — The maintenance track name for the cluster.

  **Default:** undefined - Redshift default is current

- `masterUser`: [Login](/cdk/api/v2/docs/@aws-cdk_aws-redshift-alpha.Login.html) (required) — Username and password for the administrative user.

- `multiAz`: boolean = false — Indicating whether Amazon Redshift should deploy the cluster in two Availability Zones.

- `nodeType`: [NodeType](/cdk/api/v2/docs/@aws-cdk_aws-redshift-alpha.NodeType.html) = `NodeType.RA3_LARGE` — The node type to be provisioned for the cluster.

- `numberOfNodes`: number — Number of compute nodes in the cluster. Only specify this property for multi-node clusters.

  **Default:** 2 if `clusterType` is ClusterType.MULTI_NODE, undefined otherwise

  Value must be at least 2 and no more than 100.

- `parameterGroup`: [IClusterParameterGroup](/cdk/api/v2/docs/@aws-cdk_aws-redshift-alpha.IClusterParameterGroup.html) — Additional parameters to pass to the database engine https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-parameter-groups.html.

  **Default:** No parameter group.

- `port`: number — What port to listen on.

  **Default:** The default for the engine is used.

- `preferredMaintenanceWindow`: string — A preferred maintenance window day/time range. Should be specified as a range ddd:hh24:mi-ddd:hh24:mi (24H Clock UTC).

  **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.

  Example: 'Sun:23:45-Mon:00:15'

- `publiclyAccessible`: boolean = false — Whether to make cluster publicly accessible.

- `rebootForParameterChanges`: boolean = false — If this flag is set, the cluster will be rebooted when changes to the cluster's parameter group that require a restart to apply.

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

- `resourceAction`: [ResourceAction](/cdk/api/v2/docs/@aws-cdk_aws-redshift-alpha.ResourceAction.html) — The Amazon Redshift operation to be performed.

  **Default:** no operation

- `roles`: [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.

  The maximum number of roles to attach to a cluster is subject to a quota.

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

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

- `subnetGroup`: [IClusterSubnetGroup](/cdk/api/v2/docs/@aws-cdk_aws-redshift-alpha.IClusterSubnetGroup.html) — A cluster subnet group to use with this cluster.

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

- `vpc`: [IVpc](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) (required) — The VPC to place the cluster in.

- `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-redshift-alpha.Endpoint.html) — The endpoint to use for read/write operations.

- `clusterName`: string — Identifier of the cluster.

- `connections`: [Connections](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.Connections.html) — Access to the network connections.

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — 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.

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

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

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

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

## Methods

- `addDefaultIamRole(defaultIamRole: IRole): void` — Adds default IAM role to cluster.

  The default IAM role must be already associated to the cluster to be added as the default role.

  **Parameters**

  - `defaultIamRole` — the IAM role to be set as the default role.

- `addIamRole(role: IRole): void` — Adds a role to the cluster.

  **Parameters**

  - `role` — the role to add.

- `addRotationMultiUser(id: string, options: RotationMultiUserOptions): SecretRotation` — Adds the multi user rotation to this cluster.

- `addRotationSingleUser(automaticallyAfter?: Duration): SecretRotation` — Adds the single user rotation of the master password to this cluster.

  **Parameters**

  - `automaticallyAfter` — Specifies the number of days after the previous rotation before Secrets Manager triggers the next automatic rotation.

- `addToParameterGroup(name: string, value: string): void` — Adds a parameter to the Clusters' parameter group.

  **Parameters**

  - `name` — the parameter name.
  - `value` — the parameter name.

- `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`).

- `asSecretAttachmentTarget(): SecretAttachmentTargetProps` — Renders the secret attachment target specifications.

- `enableRebootForParameterChanges(): void` — Enables automatic cluster rebooting when changes to the cluster's parameter group require a restart to apply.

- `fromClusterAttributes(scope: Construct, id: string, attrs: ClusterAttributes): ICluster` (static) — Import an existing DatabaseCluster from properties.

- `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.

- `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.
