Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
使用 Amazon 开发工具包从 IAM 生成凭证报告
以下代码示例说明如何从 IAM 生成当前账户的凭证报告。生成报告后,使用 GetCredentialReport 操作获取报告。
- Python
-
- 适用于 Python (Boto3) 的 SDK
-
def generate_credential_report():
"""
Starts generation of a credentials report about the current account. After
calling this function to generate the report, call get_credential_report
to get the latest report. A new report can be generated a minimum of four hours
after the last one was generated.
"""
try:
response = iam.meta.client.generate_credential_report()
logger.info("Generating credentials report for your account. "
"Current state is %s.", response['State'])
except ClientError:
logger.exception("Couldn't generate a credentials report for your account.")
raise
else:
return response
有关 Amazon 软件开发工具包开发人员指南和代码示例的完整列表,请参阅 将 IAM 与 Amazon 开发工具包配合使用。本主题还包括有关入门的信息以及有关先前的软件开发工具包版本的详细信息。