コード例 #1
0
 def list_from_aws(
     cls: Type["AccountResourceSpec"], client: BaseClient, account_id: str, region: str
 ) -> ListFromAWSResult:
     """This resource is somewhat synthetic, this method simply returns a dict of form
         {'account_arn': {account_dict}"""
     sts_account_id = client.get_caller_identity()["Account"]
     if sts_account_id != account_id:
         raise ValueError(f"BUG: sts detected account_id {sts_account_id} != {account_id}")
     accounts = {f"arn:aws::::account/{sts_account_id}": {"account_id": sts_account_id}}
     return ListFromAWSResult(resources=accounts)
コード例 #2
0
def _get_account_and_user(*, sts_client: BaseClient) -> Tuple[str, str]:
    """ This is an internal API not intended for public use """
    identity = sts_client.get_caller_identity()
    arn = identity["Arn"]
    return identity["Account"], arn.split("/")[-1]