airflow.providers.amazon.aws.hooks.redshift_cluster

Module Contents

Classes

RedshiftHook

Interact with Amazon Redshift.

RedshiftAsyncHook

Interact with AWS Redshift using aiobotocore library

class airflow.providers.amazon.aws.hooks.redshift_cluster.RedshiftHook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook

Interact with Amazon Redshift. Provide thin wrapper around boto3.client("redshift").

Additional arguments (such as aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.

template_fields: Sequence[str] = ('cluster_identifier',)[source]
create_cluster(cluster_identifier, node_type, master_username, master_user_password, params)[source]

Creates a new cluster with the specified parameters

Parameters
  • cluster_identifier (str) – A unique identifier for the cluster.

  • node_type (str) – The node type to be provisioned for the cluster. Valid Values: ds2.xlarge, ds2.8xlarge, dc1.large, dc1.8xlarge, dc2.large, dc2.8xlarge, ra3.xlplus, ra3.4xlarge, and ra3.16xlarge.

  • master_username (str) – The username associated with the admin user account for the cluster that is being created.

  • master_user_password (str) – password associated with the admin user account for the cluster that is being created.

  • params (dict[str, Any]) – Remaining AWS Create cluster API params.

cluster_status(cluster_identifier)[source]

Return status of a cluster

Parameters
  • cluster_identifier (str) – unique identifier of a cluster

  • skip_final_cluster_snapshot – determines cluster snapshot creation

  • final_cluster_snapshot_identifier – Optional[str]

delete_cluster(cluster_identifier, skip_final_cluster_snapshot=True, final_cluster_snapshot_identifier=None)[source]

Delete a cluster and optionally create a snapshot

Parameters
  • cluster_identifier (str) – unique identifier of a cluster

  • skip_final_cluster_snapshot (bool) – determines cluster snapshot creation

  • final_cluster_snapshot_identifier (str | None) – name of final cluster snapshot

describe_cluster_snapshots(cluster_identifier)[source]

Gets a list of snapshots for a cluster

Parameters

cluster_identifier (str) – unique identifier of a cluster

restore_from_cluster_snapshot(cluster_identifier, snapshot_identifier)[source]

Restores a cluster from its snapshot

Parameters
  • cluster_identifier (str) – unique identifier of a cluster

  • snapshot_identifier (str) – unique identifier for a snapshot of a cluster

create_cluster_snapshot(snapshot_identifier, cluster_identifier, retention_period=-1)[source]

Creates a snapshot of a cluster

Parameters
  • snapshot_identifier (str) – unique identifier for a snapshot of a cluster

  • cluster_identifier (str) – unique identifier of a cluster

  • retention_period (int) – The number of days that a manual snapshot is retained. If the value is -1, the manual snapshot is retained indefinitely.

get_cluster_snapshot_status(snapshot_identifier)[source]

Return Redshift cluster snapshot status. If cluster snapshot not found return None

Parameters

snapshot_identifier (str) – A unique identifier for the snapshot that you are requesting

class airflow.providers.amazon.aws.hooks.redshift_cluster.RedshiftAsyncHook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsBaseAsyncHook

Interact with AWS Redshift using aiobotocore library

async cluster_status(cluster_identifier, delete_operation=False)[source]

Connects to the AWS redshift cluster via aiobotocore and get the status and returns the status of the cluster based on the cluster_identifier passed

Parameters
  • cluster_identifier (str) – unique identifier of a cluster

  • delete_operation (bool) – whether the method has been called as part of delete cluster operation

async pause_cluster(cluster_identifier, poll_interval=5.0)[source]

Connects to the AWS redshift cluster via aiobotocore and pause the cluster based on the cluster_identifier passed

Parameters
  • cluster_identifier (str) – unique identifier of a cluster

  • poll_interval (float) – polling period in seconds to check for the status

async resume_cluster(cluster_identifier, polling_period_seconds=5.0)[source]

Connects to the AWS redshift cluster via aiobotocore and resume the cluster for the cluster_identifier passed

Parameters
  • cluster_identifier (str) – unique identifier of a cluster

  • polling_period_seconds (float) – polling period in seconds to check for the status

async get_cluster_status(cluster_identifier, expected_state, flag, delete_operation=False)[source]

check for expected Redshift cluster state

Parameters
  • cluster_identifier (str) – unique identifier of a cluster

  • expected_state (str) – expected_state example(“available”, “pausing”, “paused””)

  • flag (asyncio.Event) – asyncio even flag set true if success and if any error

  • delete_operation (bool) – whether the method has been called as part of delete cluster operation

Was this entry helpful?