Sono disponibili altri esempi AWS SDK nel repository AWS Doc SDK Examples. GitHub
Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.
Utilizzo GenerateCredentialReport
con un AWS SDK o una CLI
Gli esempi di codice seguenti mostrano come utilizzare GenerateCredentialReport
.
Gli esempi di operazioni sono estratti di codice da programmi più grandi e devono essere eseguiti nel contesto. È possibile visualizzare questa operazione nel contesto nel seguente esempio di codice:
- CLI
-
- AWS CLI
-
Come generare un report delle credenziali
L'esempio seguente tenta di generare un rapporto sulle credenziali per l' AWS account.
aws iam generate-credential-report
Output:
{
"State": "STARTED",
"Description": "No report exists. Starting a new report generation task"
}
Per ulteriori informazioni, consulta Ottenere i report sulle credenziali per il tuo AWS account nella AWS IAM User Guide.
- PowerShell
-
- Strumenti per PowerShell V4
-
Esempio 1: questo esempio richiede la generazione di un nuovo report, operazione che può essere eseguita ogni quattro ore. Se l'ultimo repprt è ancora recente, il campo Stato riporta COMPLETE
. Utilizzare Get-IAMCredentialReport
per visualizzare il report completato.
Request-IAMCredentialReport
Output:
Description State
----------- -----
No report exists. Starting a new report generation task STARTED
- Python
-
- SDK per 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