def AccountAlias(self) -> str: """ Returns the human readable account alias """ if self.__AccountAlias is None: self.__AccountAlias = get_account_alias() return self.__AccountAlias
def get_mint_bucket_name(region: str): account_id = get_account_id() account_alias = get_account_alias() s3 = boto3.resource('s3') parts = account_alias.split('-') prefix = parts[0] bucket_name = '{}-stups-mint-{}-{}'.format(prefix, account_id, region) bucket = s3.Bucket(bucket_name) try: bucket.load() return bucket.name except: bucket = None for bucket in s3.buckets.all(): if bucket.name.startswith('{}-stups-mint-{}-'.format(prefix, account_id)): return bucket.name return bucket_name
def test_get_account_alias(monkeypatch): boto3 = MagicMock() boto3.list_account_aliases.return_value = {'AccountAliases': ['org-dummy']} monkeypatch.setattr('boto3.client', MagicMock(return_value=boto3)) assert 'org-dummy' == get_account_alias()
def test_get_account_alias(monkeypatch): boto3 = MagicMock() boto3.list_account_aliases.return_value = {"AccountAliases": ["org-dummy"]} monkeypatch.setattr("boto3.client", MagicMock(return_value=boto3)) assert "org-dummy" == get_account_alias()