Amazon Redshift Operators¶
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.
Airflow provides operators to manage your Redshift clusters.
Prerequisite Tasks¶
To use these operators, you must do a few things:
Create necessary resources using AWS Console or AWS CLI.
Install API libraries via pip.
pip install 'apache-airflow[amazon]'
Detailed information is available Installation
Manage Amazon Redshift Clusters¶
Amazon Redshift Cluster Sensor¶
To check the state of an Amazon Redshift Cluster until it reaches the target state or another terminal
state you can use RedshiftClusterSensor
.
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,
)
Resume an Amazon Redshift Cluster¶
To resume a 'paused' Amazon Redshift Cluster you can use
RedshiftResumeClusterOperator
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
task_pause_cluster = RedshiftPauseClusterOperator(
task_id='redshift_pause_cluster',
cluster_identifier=REDSHIFT_CLUSTER_IDENTIFIER,
)