diff --git a/cid/helpers/quicksight/__init__.py b/cid/helpers/quicksight/__init__.py index ac8dd19b..90303e5a 100644 --- a/cid/helpers/quicksight/__init__.py +++ b/cid/helpers/quicksight/__init__.py @@ -93,7 +93,7 @@ def identityRegion(self) -> str: except self.client.exceptions.AccessDeniedException as exc: logger.debug(exc) pattern = f'Operation is being called from endpoint {self.region}, but your identity region is (.*). Please use the (.*) endpoint.' - match = re.search(pattern, e.response['Error']['Message']) + match = re.search(pattern, exc.response['Error']['Message']) if match: logger.info(f'Switching QuickSight identity region to {match.group(1)}') self._identityRegion = match.group(1) diff --git a/cid/helpers/s3.py b/cid/helpers/s3.py index 7d350733..cc27e1eb 100644 --- a/cid/helpers/s3.py +++ b/cid/helpers/s3.py @@ -23,10 +23,18 @@ def ensure_bucket(self, name: str) -> str: if int(ex.response['Error']['Code']) != 404: raise CidError(f"Cannot check bucket {ex}!") + parameters = { + 'ACL': 'private', + 'Bucket': name + } + + if self.region != 'us-east-1': + parameters.update({'CreateBucketConfiguration': {'LocationConstraint': self.region}}) + response = self.client.create_bucket( - ACL='private', - Bucket=name + **parameters ) + response = self.client.put_bucket_encryption( Bucket=name, ServerSideEncryptionConfiguration={