Skip to content

Commit

Permalink
make url compatibile with China regions (#738)
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov-aws authored Feb 6, 2024
1 parent 9c3b904 commit 1d6c489
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions cid/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ def __init__(self, session: Session) -> None:
def account_id(self) -> str:
return self.awsIdentity.get('Account')

@property
def domain(self) -> str:
if self.region.startswith('cn-'):
return 'amazonaws.cn'
return 'aws.amazon.com'

@property
def awsIdentity(self) -> dict:
if not self._awsIdentity:
Expand Down
5 changes: 3 additions & 2 deletions cid/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, **kwargs) -> None:
self.plugins = self.__loadPlugins()
self._clients = dict()
self._visited_views = [] # Views updated in the current session
self.qs_url = 'https://{region}.quicksight.aws.amazon.com/sn/dashboards/{dashboard_id}'
self.qs_url = 'https://{region}.quicksight.{domain}/sn/dashboards/{dashboard_id}'
self.all_yes = kwargs.get('yes')
self.verbose = kwargs.get('verbose')
set_parameters(kwargs, self.all_yes)
Expand Down Expand Up @@ -75,7 +75,8 @@ def aws_login(self):
logger.info(f'AWS profile name: {self.base.session.profile_name}')
self.qs_url_params = {
'account_id': self.base.account_id,
'region': self.base.session.region_name
'region': self.base.session.region_name,
'domain': self.base.domain,
}
except (NoCredentialsError, CredentialRetrievalError):
raise CidCritical('Error: Not authenticated, please check AWS credentials')
Expand Down

0 comments on commit 1d6c489

Please sign in to comment.