Amazon Redshift

Amazon Redshift manages all the work of setting up, operating, and scaling a data warehouse: provisioning capacity, monitoring and backing up the cluster, and applying patches and upgrades to the Amazon Redshift engine. You can focus on using your data to acquire new insights for your business and customers.

Prerequisite Tasks

To use these operators, you must do a few things:

Operators

Create an Amazon Redshift cluster

To create an Amazon Redshift Cluster with the specified parameters you can use RedshiftCreateClusterOperator.

tests/system/providers/amazon/aws/example_redshift_cluster.py[source]

task_create_cluster = RedshiftCreateClusterOperator(
    task_id="redshift_create_cluster",
    cluster_identifier=REDSHIFT_CLUSTER_IDENTIFIER,
    cluster_type="single-node",
    node_type="dc2.large",
    master_username="adminuser",
    master_user_password="dummypass",
)

Resume an Amazon Redshift cluster

To resume a 'paused' Amazon Redshift cluster you can use RedshiftResumeClusterOperator

tests/system/providers/amazon/aws/example_redshift_cluster.py[source]

task_resume_cluster = RedshiftResumeClusterOperator(
    task_id='redshift_resume_cluster',
    cluster_identifier=REDSHIFT_CLUSTER_IDENTIFIER,
)

Pause an Amazon Redshift cluster

To pause an 'available' Amazon Redshift cluster you can use RedshiftPauseClusterOperator

tests/system/providers/amazon/aws/example_redshift_cluster.py[source]

task_pause_cluster = RedshiftPauseClusterOperator(
    task_id='redshift_pause_cluster',
    cluster_identifier=REDSHIFT_CLUSTER_IDENTIFIER,
)

Create an Amazon Redshift cluster snapshot

To create Amazon Redshift cluster snapshot you can use RedshiftCreateClusterSnapshotOperator

tests/system/providers/amazon/aws/example_redshift_cluster.py[source]

task_create_cluster_snapshot = RedshiftCreateClusterSnapshotOperator(
    task_id='create_cluster_snapshot',
    cluster_identifier=REDSHIFT_CLUSTER_IDENTIFIER,
    snapshot_identifier=REDSHIFT_CLUSTER_SNAPSHOT_IDENTIFIER,
    retention_period=1,
    wait_for_completion=True,
)

Delete an Amazon Redshift cluster snapshot

To delete Amazon Redshift cluster snapshot you can use RedshiftDeleteClusterSnapshotOperator

tests/system/providers/amazon/aws/example_redshift_cluster.py[source]

task_delete_cluster_snapshot = RedshiftDeleteClusterSnapshotOperator(
    task_id='delete_cluster_snapshot',
    cluster_identifier=REDSHIFT_CLUSTER_IDENTIFIER,
    snapshot_identifier=REDSHIFT_CLUSTER_SNAPSHOT_IDENTIFIER,
)

Delete an Amazon Redshift cluster

To delete an Amazon Redshift cluster you can use RedshiftDeleteClusterOperator

tests/system/providers/amazon/aws/example_redshift_cluster.py[source]

task_delete_cluster = RedshiftDeleteClusterOperator(
    task_id="delete_cluster",
    cluster_identifier=REDSHIFT_CLUSTER_IDENTIFIER,
    trigger_rule=TriggerRule.ALL_DONE,
)

Sensors

Wait on an Amazon Redshift cluster state

To check the state of an Amazon Redshift Cluster until it reaches the target state or another terminal state you can use RedshiftClusterSensor.

tests/system/providers/amazon/aws/example_redshift_cluster.py[source]

task_wait_cluster_available = RedshiftClusterSensor(
    task_id='sensor_redshift_cluster_available',
    cluster_identifier=REDSHIFT_CLUSTER_IDENTIFIER,
    target_status='available',
    poke_interval=5,
    timeout=60 * 15,
)

Was this entry helpful?