Skip to content

Commit

Permalink
Bugfix for workgroup creation in non us-east-1 region (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborschulz-aws authored Oct 12, 2023
1 parent cd9e81f commit 3ab6d84
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cid/helpers/quicksight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions cid/helpers/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={
Expand Down

0 comments on commit 3ab6d84

Please sign in to comment.