# RedshiftQueryProps

Configuration properties of an Amazon Redshift Query event.

Extends: RedshiftQueryProps
Used as props by: RedshiftQuery

- Source: [`aws-events-targets/lib/redshift-query.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-events-targets/lib/redshift-query.ts#L12)
- Type last changed: v2.156.0 · 6 Sep 2024

## Example

```ts
import * as redshiftserverless from 'aws-cdk-lib/aws-redshiftserverless'

declare const workgroup: redshiftserverless.CfnWorkgroup;

const rule = new events.Rule(this, 'Rule', {
  schedule: events.Schedule.rate(cdk.Duration.hours(1)),
});

const dlq = new sqs.Queue(this, 'DeadLetterQueue');

rule.addTarget(new targets.RedshiftQuery(workgroup.attrWorkgroupWorkgroupArn, {
  database: 'dev',
  deadLetterQueue: dlq,
  sql: ['SELECT * FROM foo','SELECT * FROM baz'],
}));
```

## Properties

- `database`: string (required) — The Amazon Redshift database to run the query against.

- `dbUser`: string — The Amazon Redshift database user to run the query as.

  **Default:** No Database user is specified

  This is required when authenticating via temporary credentials.

- `deadLetterQueue`: [IQueue](/cdk/api/v2/docs/aws-cdk-lib.aws_sqs.IQueue.html) — The queue to be used as dead letter queue.

  **Default:** No dead letter queue is specified

- `input`: [RuleTargetInput](/cdk/api/v2/docs/aws-cdk-lib.aws_events.RuleTargetInput.html) — The input to the state machine execution.

  **Default:** the entire EventBridge event

- `role`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The IAM role to be used to execute the SQL statement.

  **Default:** a new role will be created.

- `secret`: [ISecret](/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager.ISecret.html) — The secret containing the password for the database user.

  **Default:** No secret is specified

  This is required when authenticating via Secrets Manager.
  If the full secret ARN is not specified, this will instead use the secret name.

- `sendEventBridgeEvent`: boolean = false — Should an event be sent back to Event Bridge when the SQL statement is executed.

- `sql`: string[] (required) — The SQL queries to be executed.

  **Default:** No SQL query is specified

  Each query is run sequentially within a single transaction; the next query in the array will only execute after the previous one has successfully completed.

  - When multiple sql queries are included, this will use the `batchExecuteStatement` API. Therefore, if any statement fails, the entire transaction is rolled back.
  - If a single SQL statement is to be executed, this will use the `executeStatement` API.

- `statementName`: string — The name of the SQL statement.

  **Default:** No statement name is specified

  You can name the SQL statement for identitfication purposes. If you would like Amazon Redshift to identify the Event Bridge rule, and present it in the Amazon Redshift console, append a `QS2-` prefix to the statement name.
