You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/05/17 19:30:18 UTC

[GitHub] [airflow] JeffryMAC commented on a change in pull request #8895: S3 operators

JeffryMAC commented on a change in pull request #8895:
URL: https://github.com/apache/airflow/pull/8895#discussion_r426295941



##########
File path: airflow/providers/amazon/aws/operators/s3_bucket.py
##########
@@ -0,0 +1,132 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+This module contains AWS S3 operators.
+"""
+from typing import Optional, Union
+
+from botocore.config import Config
+
+from airflow.exceptions import AirflowException
+from airflow.models import BaseOperator
+from airflow.providers.amazon.aws.hooks.s3 import S3Hook
+
+
+class S3CreateBucketOperator(BaseOperator):
+    """
+    This operator creates an S3 bucket
+
+    :param bucket_name: This is bucket name you want to create
+    :type bucket_name: Optional[str]
+    :param aws_conn_id: 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).
+    :type aws_conn_id: Optional[str]
+    :param verify: Whether or not to verify SSL certificates.
+    :type verify: Union[bool, str, None]
+    :param region_name: AWS region_name. If not specified then the default boto3 behaviour is used.
+    :type region_name: Optional[str]
+    :param config: Configuration for botocore client.
+        (https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html)
+    :type config: Optional[botocore.client.Config]
+    """
+    def __init__(self,
+                 bucket_name,
+                 aws_conn_id: Optional[str] = "aws_default",
+                 verify: Union[bool, str, None] = None,
+                 region_name: Optional[str] = None,
+                 config: Optional[Config] = None,
+                 *args,
+                 **kwargs) -> None:
+        super().__init__(*args, **kwargs)
+        self.bucket_name = bucket_name
+        self.region_name = region_name
+        self.s3_hook = S3Hook(aws_conn_id=aws_conn_id,
+                              verify=verify,
+                              region_name=region_name,

Review comment:
       I believe region can be provided from the AWS connection as well.
   If the constructor wasn't set with `region_name` you should use the default of AWS connection and only if it's not set there then use None.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org