Use GenerateCredentialReport with an Amazon SDK or CLI
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-reportOutput:
{ "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. -
For API details, see GenerateCredentialReport
in Amazon CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
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. UseGet-IAMCredentialReportto view the completed report.Request-IAMCredentialReportOutput:
Description State ----------- ----- No report exists. Starting a new report generation task STARTED-
For API details, see GenerateCredentialReport
in Amazon Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
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. UseGet-IAMCredentialReportto view the completed report.Request-IAMCredentialReportOutput:
Description State ----------- ----- No report exists. Starting a new report generation task STARTED-
For API details, see GenerateCredentialReport
in Amazon Tools for PowerShell Cmdlet Reference (V5).
-
- Python
-
- SDK for Python (Boto3)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository
. 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 API details, see GenerateCredentialReport in Amazon SDK for Python (Boto3) API Reference.
-
- SAP ABAP
-
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the Amazon Code Examples Repository
. TRY. oo_result = lo_iam->generatecredentialreport( ). MESSAGE 'Credential report generation started.' TYPE 'I'. CATCH /aws1/cx_iamlimitexceededex. MESSAGE 'Report generation limit exceeded.' TYPE 'E'. CATCH /aws1/cx_iamservicefailureex. MESSAGE 'Service failure when generating credential report.' TYPE 'E'. ENDTRY.-
For API details, see GenerateCredentialReport in Amazon SDK for SAP ABAP API reference.
-
For a complete list of Amazon SDK developer guides and code examples, see Using this service with an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.