airflow.providers.amazon.aws.transfers.s3_to_sftp

Classes

S3ToSFTPOperator

This operator enables the transferring of files from S3 to a SFTP server.

Module Contents

class airflow.providers.amazon.aws.transfers.s3_to_sftp.S3ToSFTPOperator(*, s3_bucket, s3_key, sftp_path, sftp_conn_id='ssh_default', sftp_remote_host='', aws_conn_id='aws_default', s3_filenames=None, sftp_filenames=None, confirm=True, fail_on_file_not_exist=True, **kwargs)[source]

Bases: airflow.providers.common.compat.sdk.BaseOperator

This operator enables the transferring of files from S3 to a SFTP server.

See also

For more information on how to use this operator, take a look at the guide: Amazon S3 To SFTP transfer operator

Parameters:
  • sftp_conn_id (str) – The sftp connection id. The name or identifier for establishing a connection to the SFTP server.

  • sftp_path (str) – The sftp remote path. For a single file it must include the file path. For multiple files it is the destination directory path and must end with "/".

  • sftp_remote_host (str) – The remote host of the SFTP server. Overrides host in Connection.

  • aws_conn_id (str | None) – The Airflow connection used for AWS credentials. If this is None or empty then the default boto3 behaviour is used. If running Airflow in a distributed manner and aws_conn_id is None or empty, then default boto3 configuration would be used (and must be maintained on each worker node).

  • s3_bucket (str) – The targeted s3 bucket. This is the S3 bucket from where the file is downloaded.

  • s3_key (str) – The targeted s3 key. For a single file it must include the file path. For multiple files it is the key prefix (directory) and must end with "/".

  • s3_filenames (str | list[str] | None) – Only used if you want to move multiple files. You can pass a list with exact key suffixes present under the s3_key prefix, or a string prefix that all filenames must match. Use "*" to move all objects under the s3_key prefix.

  • sftp_filenames (str | list[str] | None) – Only used if you want to move multiple files and name them differently at the destination. It can be a list of filenames or a string prefix that replaces the s3 prefix.

  • confirm (bool) – specify if the SFTP operation should be confirmed, defaults to True. When True, a stat will be performed on the remote file after upload to verify the file size matches and confirm successful transfer.

  • fail_on_file_not_exist (bool) – If True, operator fails when a source S3 key does not exist. If False, the operator logs a warning and skips the transfer. Default is True.

template_fields: collections.abc.Sequence[str] = ('s3_key', 'sftp_path', 's3_bucket', 's3_filenames', 'sftp_filenames')[source]
sftp_conn_id = 'ssh_default'[source]
sftp_path[source]
s3_bucket[source]
s3_key[source]
sftp_remote_host = ''[source]
aws_conn_id = 'aws_default'[source]
s3_filenames = None[source]
sftp_filenames = None[source]
confirm = True[source]
fail_on_file_not_exist = True[source]
static get_s3_key(s3_key)[source]

Parse the correct format for S3 keys regardless of how the S3 url is passed.

execute(context)[source]

Derive when creating an operator.

The main method to execute the task. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

Was this entry helpful?