Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Use GenerateCredentialReport
with an Amazon SDK or command line tool
The following code examples show how to use GenerateCredentialReport
.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in
context in the following code example:
- CLI
-
- Amazon CLI
-
To generate a credential report
The following example attempts to generate a credential report for the Amazon account.
aws iam generate-credential-report
Output:
{
"State": "STARTED",
"Description": "No report exists. Starting a new report generation task"
}
For more information, see Getting credential reports for your Amazon account in the Amazon IAM User Guide.
- PowerShell
-
- Tools for PowerShell
-
Example 1: This example requests generation of a new report, which can be done every four hours. If the last report is still recent the State field reads COMPLETE
. Use Get-IAMCredentialReport
to view the completed report.
Request-IAMCredentialReport
Output:
Description State
----------- -----
No report exists. Starting a new report generation task STARTED
- Python
-
- SDK for Python (Boto3)
-
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
For a complete list of Amazon SDK developer guides and code examples, see
Using IAM with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.