Apache Airflow:操作员将s3复制到s3 [英] Apache Airflow: operator to copy s3 to s3

查看:111
本文介绍了Apache Airflow:操作员将s3复制到s3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将文件从一个s3复制到另一个s3的最佳方法是什么?
我已经尝试过S3FileTransformOperator,但是它需要transform_script或select_expression。我的要求是将确切的文件从源复制到目标。

What is the best operator to copy a file from one s3 to another s3 in airflow? I tried S3FileTransformOperator already but it required either transform_script or select_expression. My requirement is to copy the exact file from source to destination.

推荐答案

您有2个选择(即使我不考虑 Airflow

You have 2 options (even when I disregard Airflow)


  1. 使用 AWS CLI cp 命令


    • aws s3 cp< source> <目的地>

    • 气流中,可以使用 BashOperator运行此命令(本地计算机)或 SSHOperator (远程计算机)

  1. Use AWS CLI: cp command
    • aws s3 cp <source> <destination>
    • In Airflow this command can be run using BashOperator (local machine) or SSHOperator (remote machine)
  • Here you'll be using boto3's S3Client
  • Airflow already provides a wrapper over it in form of S3Hook
  • Even copy_object(..) method of S3Client is available in S3Hook as (again) copy_object(..)
  • You can use S3Hook inside any suitable custom operator or just PythonOperator

这篇关于Apache Airflow:操作员将s3复制到s3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆