S3ToGCSOperator

Google

Synchronizes an S3 key, possibly a prefix, with a Google Cloud Storage destination path.

View on GitHub

Last Updated: Jan. 23, 2023

Access Instructions

Install the Google provider package into your Airflow environment.

Import the module into your DAG file and instantiate it with your desired params.

Parameters

bucketRequiredThe S3 bucket where to find the objects. (templated)
prefixPrefix string which filters objects whose name begin with such prefix. (templated)
delimiterthe delimiter marks key hierarchy. (templated)
aws_conn_idThe source S3 connection
verifyWhether or not to verify SSL certificates for S3 connection. By default SSL certificates are verified. You can provide the following values: False: do not validate SSL certificates. SSL will still be used(unless use_ssl is False), but SSL certificates will not be verified. path/to/cert/bundle.pem: A filename of the CA cert bundle to uses.You can specify this argument if you want to use a different CA cert bundle than the one used by botocore.
gcp_conn_id(Optional) The connection ID used to connect to Google Cloud.
dest_gcsThe destination Google Cloud Storage bucket and prefix where you want to store the files. (templated)
delegate_toGoogle account to impersonate using domain-wide delegation of authority, if any. For this to work, the service account making the request must have domain-wide delegation enabled.
replaceWhether you want to replace existing destination files or not.
gzipOption to compress file for upload
google_impersonation_chainOptional Google service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account (templated).

Documentation

Synchronizes an S3 key, possibly a prefix, with a Google Cloud Storage destination path.

See also

For more information on how to use this operator, take a look at the guide: Transfer Data from Amazon S3 to Google Cloud Storage

Example:

s3_to_gcs_op = S3ToGCSOperator(
task_id="s3_to_gcs_example",
bucket="my-s3-bucket",
prefix="data/customers-201804",
gcp_conn_id="google_cloud_default",
dest_gcs="gs://my.gcs.bucket/some/customers/",
replace=False,
gzip=True,
dag=my_dag,
)

Note that bucket, prefix, delimiter and dest_gcs are templated, so you can use variables in them if you wish.

Was this page helpful?