def get_account_id(self):
try:
client = boto3.client('sts',
aws_access_key_id=self.access_key_id,
aws_secret_access_key=self.secret_access_key,
region_name=self.region_name)
except Exception as e:
raise AWSException("There was an error connecting to EC2: %s" % e)
try:
return client.get_caller_identity()["Account"]
except botocore.exceptions.ClientError as e:
raise AWSException("There was an error getting the Account ID: %s" %
e.response["Error"]["Message"])
评论列表
文章目录