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)
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
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)
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)