RedshiftQueryProps
- class aws_cdk.aws_events_targets.RedshiftQueryProps(*, database, sql, db_user=None, dead_letter_queue=None, input=None, role=None, secret=None, send_event_bridge_event=None, statement_name=None)
Bases:
object
Configuration properties of an Amazon Redshift Query event.
- Parameters:
database (
str
) – The Amazon Redshift database to run the query against.sql (
Sequence
[str
]) – The SQL queries to be executed. 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 thebatchExecuteStatement
API. Therefore, if any statement fails, the entire transaction is rolled back. - If a single SQL statement is to be executed, this will use theexecuteStatement
API. Default: - No SQL query is specifieddb_user (
Optional
[str
]) – The Amazon Redshift database user to run the query as. This is required when authenticating via temporary credentials. Default: - No Database user is specifieddead_letter_queue (
Optional
[IQueue
]) – The queue to be used as dead letter queue. Default: - No dead letter queue is specifiedinput (
Optional
[RuleTargetInput
]) – The input to the state machine execution. Default: - the entire EventBridge eventrole (
Optional
[IRole
]) – The IAM role to be used to execute the SQL statement. Default: - a new role will be created.secret (
Optional
[ISecret
]) – The secret containing the password for the database user. This is required when authenticating via Secrets Manager. If the full secret ARN is not specified, this will instead use the secret name. Default: - No secret is specifiedsend_event_bridge_event (
Optional
[bool
]) – Should an event be sent back to Event Bridge when the SQL statement is executed. Default: falsestatement_name (
Optional
[str
]) – The name of the SQL statement. 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 aQS2-
prefix to the statement name. Default: - No statement name is specified
- ExampleMetadata:
infused
Example:
import aws_cdk.aws_redshiftserverless as redshiftserverless # workgroup: redshiftserverless.CfnWorkgroup rule = events.Rule(self, "Rule", schedule=events.Schedule.rate(cdk.Duration.hours(1)) ) dlq = sqs.Queue(self, "DeadLetterQueue") rule.add_target(targets.RedshiftQuery(workgroup.attr_workgroup_workgroup_arn, database="dev", dead_letter_queue=dlq, sql=["SELECT * FROM foo", "SELECT * FROM baz"] ))
Attributes
- database
The Amazon Redshift database to run the query against.
- db_user
The Amazon Redshift database user to run the query as.
This is required when authenticating via temporary credentials.
- Default:
No Database user is specified
- dead_letter_queue
The queue to be used as dead letter queue.
- Default:
No dead letter queue is specified
- input
The input to the state machine execution.
- Default:
the entire EventBridge event
- role
The IAM role to be used to execute the SQL statement.
- Default:
a new role will be created.
- secret
The secret containing the password for the database user.
This is required when authenticating via Secrets Manager. If the full secret ARN is not specified, this will instead use the secret name.
- Default:
No secret is specified
- send_event_bridge_event
Should an event be sent back to Event Bridge when the SQL statement is executed.
- Default:
false
- sql
The SQL queries to be executed.
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.
- Default:
No SQL query is specified
- statement_name
The name of the SQL statement.
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.- Default:
No statement name is specified