Esempio n. 1
0
    def create_bucket(self, bucket_name, region=None):
        """Create a bucket on S3 with a location constraint
        matching the given region.

        .. versionchanged:: 0.6.0

           The *region* argument used to be called *location*.
        """
        client = self.make_s3_client()

        conf = {}
        if region and region != _S3_REGION_WITH_NO_LOCATION_CONSTRAINT:
            conf['LocationConstraint'] = region

        client.create_bucket(Bucket=bucket_name,
                             CreateBucketConfiguration=conf)
Esempio n. 2
0
File: s3.py Progetto: poteman/mrjob
    def create_bucket(self, bucket_name, region=None):
        """Create a bucket on S3 with a location constraint
        matching the given region.

        .. versionchanged:: 0.6.0

           The *region* argument used to be called *location*.
        """
        client = self.make_s3_client()

        conf = {}
        if region and region != _S3_REGION_WITH_NO_LOCATION_CONSTRAINT:
            conf['LocationConstraint'] = region

        client.create_bucket(Bucket=bucket_name,
                             CreateBucketConfiguration=conf)
Esempio n. 3
0
def create_bucket(bucket_name: str) -> str:

    client = boto3.client('s3')
    region = os.environ.get('AWS_DEFAULT_REGION', 'us-east-1')

    kw = {'Bucket': bucket_name}
    kw.update({CreateBucketConfiguration: {
        'LocationConstraint': region
    }} if region != 'us-east-1' else {})

    try:
        client.create_bucket(**kw)
    except botocore.exceptions.ClientError as ex:
        logger.exception(ex)
        sys.exit(1)

    return bucket_name
Esempio n. 4
0
File: s3.py Progetto: jgressma/mrjob
    def create_bucket(self, bucket_name, region=None):
        """Create a bucket on S3 with a location constraint
        matching the given region.
        """
        client = self.make_s3_client()

        params = dict(Bucket=bucket_name)

        if region is None:
            region = self._s3_region

        # CreateBucketConfiguration can't be empty, so don't set it
        # unless there's a location constraint (see #1927)
        if region and region != _S3_REGION_WITH_NO_LOCATION_CONSTRAINT:
            params['CreateBucketConfiguration'] = dict(
                LocationConstraint=region)

        client.create_bucket(**params)
Esempio n. 5
0
File: s3.py Progetto: Affirm/mrjob
    def create_bucket(self, bucket_name, region=None):
        """Create a bucket on S3 with a location constraint
        matching the given region.

        .. versionchanged:: 0.6.0

           The *region* argument used to be called *location*.
        """
        client = self.make_s3_client()

        params = dict(Bucket=bucket_name)

        # CreateBucketConfiguration can't be empty, so don't set it
        # unless there's a location constraint (see #1927)
        if region != _S3_REGION_WITH_NO_LOCATION_CONSTRAINT:
            params['CreateBucketConfiguration'] = dict(
                LocationConstraint=region)

        client.create_bucket(**params)
Esempio n. 6
0
    def create_bucket(self, bucket_name, region=None):
        """Create a bucket on S3 with a location constraint
        matching the given region.

        .. versionchanged:: 0.6.0

           The *region* argument used to be called *location*.
        """
        client = self.make_s3_client()

        params = dict(Bucket=bucket_name)

        # CreateBucketConfiguration can't be empty, so don't set it
        # unless there's a location constraint (see #1927)
        if region != _S3_REGION_WITH_NO_LOCATION_CONSTRAINT:
            params['CreateBucketConfiguration'] = dict(
                LocationConstraint=region)

        client.create_bucket(**params)