From c4f16ab622bd9b227a5e9d9689024bb444e20870 Mon Sep 17 00:00:00 2001 From: Gabor Schulz Date: Thu, 12 Oct 2023 13:07:09 +0200 Subject: [PATCH 1/3] Bugfix for workgroup creation --- cid/helpers/athena.py | 2 +- cid/helpers/s3.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cid/helpers/athena.py b/cid/helpers/athena.py index da457e30..2d3588dd 100644 --- a/cid/helpers/athena.py +++ b/cid/helpers/athena.py @@ -167,7 +167,7 @@ def WorkGroup(self, name: str): def _ensure_workgroup(self, name: str) -> str: try: s3 = S3(session=self.session) - bucket_name = f'{self.partition}-athena-query-results-cid-{self.account_id}-{self.region}' + bucket_name = f'{self.partition}-athena-query-results-cid-{self.account_id}-{self.region}-debug' workgroup = self.client.get_work_group(WorkGroup=name) # "${AWS::Partition}-athena-query-results-cid-${AWS::AccountId}-${AWS::Region}" 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={ From 0ad42ea5f3a307af6b4b2bbe83012cae741737e3 Mon Sep 17 00:00:00 2001 From: Gabor Schulz Date: Thu, 12 Oct 2023 13:07:30 +0200 Subject: [PATCH 2/3] Bugfix for invalid variable name --- cid/helpers/quicksight/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From b1c1fa9dce7b95444d2a290daf0a280f13dc8258 Mon Sep 17 00:00:00 2001 From: Gabor Schulz Date: Thu, 12 Oct 2023 13:09:44 +0200 Subject: [PATCH 3/3] Removed redundancy --- cid/helpers/athena.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cid/helpers/athena.py b/cid/helpers/athena.py index 2d3588dd..da457e30 100644 --- a/cid/helpers/athena.py +++ b/cid/helpers/athena.py @@ -167,7 +167,7 @@ def WorkGroup(self, name: str): def _ensure_workgroup(self, name: str) -> str: try: s3 = S3(session=self.session) - bucket_name = f'{self.partition}-athena-query-results-cid-{self.account_id}-{self.region}-debug' + bucket_name = f'{self.partition}-athena-query-results-cid-{self.account_id}-{self.region}' workgroup = self.client.get_work_group(WorkGroup=name) # "${AWS::Partition}-athena-query-results-cid-${AWS::AccountId}-${AWS::Region}"