阿里巴巴雲端 OSS 運算子¶
建立和刪除阿里巴巴雲端 OSS 儲存桶¶
目的¶
這個範例 DAG 使用 OSSCreateBucketOperator
和 OSSDeleteBucketOperator
來建立一個具有指定儲存桶名稱的新 OSS 儲存桶,然後將其刪除。
定義任務¶
在以下程式碼中,我們建立一個新的儲存桶,然後刪除該儲存桶。
with DAG(
dag_id=DAG_ID,
start_date=datetime(2021, 1, 1),
schedule=None,
default_args={"bucket_name": "your bucket", "region": "your region"},
max_active_runs=1,
tags=["example"],
catchup=False,
) as dag:
create_bucket = OSSCreateBucketOperator(task_id="task1", region=REGION)
delete_bucket = OSSDeleteBucketOperator(task_id="task2", region=REGION)
create_bucket >> delete_bucket
from tests_common.test_utils.watcher import watcher
# This test needs watcher in order to properly mark success/failure
# when "tearDown" task with trigger rule is part of the DAG
list(dag.tasks) >> watcher()