Supporto esempi utilizzando AWS CLI - AWS Esempi di codice SDK

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à.

Supporto esempi utilizzando AWS CLI

I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando AWS Command Line Interface with Supporto.

Le operazioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le operazioni mostrino come richiamare le singole funzioni del servizio, è possibile visualizzarle contestualizzate negli scenari correlati.

Ogni esempio include un collegamento al codice sorgente completo, in cui è possibile trovare istruzioni su come configurare ed eseguire il codice nel contesto.

Argomenti

Operazioni

Il seguente esempio di codice mostra come utilizzareadd-attachments-to-set.

AWS CLI

Per aggiungere un allegato a un set

L'add-attachments-to-setesempio seguente aggiunge un'immagine a un set che potete quindi specificare per una richiesta di supporto nel vostro AWS account.

aws support add-attachments-to-set \ --attachment-set-id "as-2f5a6faa2a4a1e600-mu-nk5xQlBr70-G1cUos5LZkd38KOAHZa9BMDVzNEXAMPLE" \ --attachments fileName=troubleshoot-screenshot.png,data=base64-encoded-string

Output:

{ "attachmentSetId": "as-2f5a6faa2a4a1e600-mu-nk5xQlBr70-G1cUos5LZkd38KOAHZa9BMDVzNEXAMPLE", "expiryTime": "2020-05-14T17:04:40.790+0000" }

Per ulteriori informazioni, consulta la sezione Gestione dei casi nella AWS Support User Guide.

Il seguente esempio di codice mostra come utilizzareadd-communication-to-case.

AWS CLI

Per aggiungere una comunicazione a un caso

L'add-communication-to-caseesempio seguente aggiunge comunicazioni a un caso di supporto nel tuo AWS account.

aws support add-communication-to-case \ --case-id "case-12345678910-2013-c4c1d2bf33c5cf47" \ --communication-body "I'm attaching a set of images to this case." \ --cc-email-addresses "myemail@example.com" \ --attachment-set-id "as-2f5a6faa2a4a1e600-mu-nk5xQlBr70-G1cUos5LZkd38KOAHZa9BMDVzNEXAMPLE"

Output:

{ "result": true }

Per ulteriori informazioni, consulta la sezione Gestione dei casi nella AWS Support User Guide.

Il seguente esempio di codice mostra come utilizzarecreate-case.

AWS CLI

Per creare un caso

L'create-caseesempio seguente crea una richiesta di supporto per il tuo AWS account.

aws support create-case \ --category-code "using-aws" \ --cc-email-addresses "myemail@example.com" \ --communication-body "I want to learn more about an AWS service." \ --issue-type "technical" \ --language "en" \ --service-code "general-info" \ --severity-code "low" \ --subject "Question about my account"

Output:

{ "caseId": "case-12345678910-2013-c4c1d2bf33c5cf47" }

Per ulteriori informazioni, consulta la sezione Gestione dei casi nella AWS Support User Guide.

Il seguente esempio di codice mostra come utilizzaredescribe-attachment.

AWS CLI

Per descrivere un allegato

L'describe-attachmentesempio seguente restituisce informazioni sull'allegato con l'ID specificato.

aws support describe-attachment \ --attachment-id "attachment-KBnjRNrePd9D6Jx0-Mm00xZuDEaL2JAj_0-gJv9qqDooTipsz3V1Nb19rCfkZneeQeDPgp8X1iVJyHH7UuhZDdNeqGoduZsPrAhyMakqlc60-iJjL5HqyYGiT1FG8EXAMPLE"

Output:

{ "attachment": { "fileName": "troubleshoot-screenshot.png", "data": "base64-blob" } }

Per ulteriori informazioni, consulta la sezione Gestione dei casi nella AWS Support User Guide.

Il seguente esempio di codice mostra come utilizzaredescribe-cases.

AWS CLI

Descrivere un caso

L'describe-casesesempio seguente restituisce informazioni sulla richiesta di assistenza specificata nel tuo AWS account.

aws support describe-cases \ --display-id "1234567890" \ --after-time "2020-03-23T21:31:47.774Z" \ --include-resolved-cases \ --language "en" \ --no-include-communications \ --max-item 1

Output:

{ "cases": [ { "status": "resolved", "ccEmailAddresses": [], "timeCreated": "2020-03-23T21:31:47.774Z", "caseId": "case-12345678910-2013-c4c1d2bf33c5cf47", "severityCode": "low", "language": "en", "categoryCode": "using-aws", "serviceCode": "general-info", "submittedBy": "myemail@example.com", "displayId": "1234567890", "subject": "Question about my account" } ] }

Per ulteriori informazioni, consulta la sezione Gestione dei casi nella AWS Support User Guide.

Il seguente esempio di codice mostra come utilizzaredescribe-communications.

AWS CLI

Descrivere la comunicazione più recente relativa a un caso

L'describe-communicationsesempio seguente restituisce la comunicazione più recente per il caso di assistenza specificato nel tuo AWS account.

aws support describe-communications \ --case-id "case-12345678910-2013-c4c1d2bf33c5cf47" \ --after-time "2020-03-23T21:31:47.774Z" \ --max-item 1

Output:

{ "communications": [ { "body": "I want to learn more about an AWS service.", "attachmentSet": [], "caseId": "case-12345678910-2013-c4c1d2bf33c5cf47", "timeCreated": "2020-05-12T23:12:35.000Z", "submittedBy": "Amazon Web Services" } ], "NextToken": "eyJuZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQEXAMPLE==" }

Per ulteriori informazioni, consulta la sezione Gestione dei casi nella AWS Support User Guide.

Il seguente esempio di codice mostra come utilizzaredescribe-services.

AWS CLI

Per elencare AWS i servizi e le categorie di servizi

L'describe-servicesesempio seguente elenca le categorie di servizi disponibili per la richiesta di informazioni generali.

aws support describe-services \ --service-code-list "general-info"

Output:

{ "services": [ { "code": "general-info", "name": "General Info and Getting Started", "categories": [ { "code": "charges", "name": "How Will I Be Charged?" }, { "code": "gdpr-queries", "name": "Data Privacy Query" }, { "code": "reserved-instances", "name": "Reserved Instances" }, { "code": "resource", "name": "Where is my Resource?" }, { "code": "using-aws", "name": "Using AWS & Services" }, { "code": "free-tier", "name": "Free Tier" }, { "code": "security-and-compliance", "name": "Security & Compliance" }, { "code": "account-structure", "name": "Account Structure" } ] } ] }

Per ulteriori informazioni, consulta la sezione Gestione dei casi nella AWS Support User Guide.

Il seguente esempio di codice mostra come utilizzaredescribe-severity-levels.

AWS CLI

Per elencare i livelli di gravità disponibili

L'describe-severity-levelsesempio seguente elenca i livelli di gravità disponibili per un caso di supporto.

aws support describe-severity-levels

Output:

{ "severityLevels": [ { "code": "low", "name": "Low" }, { "code": "normal", "name": "Normal" }, { "code": "high", "name": "High" }, { "code": "urgent", "name": "Urgent" }, { "code": "critical", "name": "Critical" } ] }

Per ulteriori informazioni, consulta Scelta della gravità nella AWS Support User Guide.

Il seguente esempio di codice mostra come utilizzaredescribe-trusted-advisor-check-refresh-statuses.

AWS CLI

Per elencare gli stati di aggiornamento dei controlli di AWS Trusted Advisor

L'describe-trusted-advisor-check-refresh-statusesesempio seguente elenca gli stati di aggiornamento per due controlli Trusted Advisor: Amazon S3 Bucket Permissions e IAM Use.

aws support describe-trusted-advisor-check-refresh-statuses \ --check-id "Pfx0RwqBli" "zXCkfM1nI3"

Output:

{ "statuses": [ { "checkId": "Pfx0RwqBli", "status": "none", "millisUntilNextRefreshable": 0 }, { "checkId": "zXCkfM1nI3", "status": "none", "millisUntilNextRefreshable": 0 } ] }

Per ulteriori informazioni, consulta AWS Trusted Advisor nella AWS Support User Guide.

Il seguente esempio di codice mostra come utilizzaredescribe-trusted-advisor-check-result.

AWS CLI

Per elencare i risultati di un controllo di AWS Trusted Advisor

L'describe-trusted-advisor-check-resultesempio seguente elenca i risultati del controllo IAM Use.

aws support describe-trusted-advisor-check-result \ --check-id "zXCkfM1nI3"

Output:

{ "result": { "checkId": "zXCkfM1nI3", "timestamp": "2020-05-13T21:38:05Z", "status": "ok", "resourcesSummary": { "resourcesProcessed": 1, "resourcesFlagged": 0, "resourcesIgnored": 0, "resourcesSuppressed": 0 }, "categorySpecificSummary": { "costOptimizing": { "estimatedMonthlySavings": 0.0, "estimatedPercentMonthlySavings": 0.0 } }, "flaggedResources": [ { "status": "ok", "resourceId": "47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZEXAMPLE", "isSuppressed": false } ] } }

Per ulteriori informazioni, consulta AWS Trusted Advisor nella AWS Support User Guide.

Il seguente esempio di codice mostra come utilizzaredescribe-trusted-advisor-check-summaries.

AWS CLI

Per elencare i riepiloghi dei controlli di AWS Trusted Advisor

L'describe-trusted-advisor-check-summariesesempio seguente elenca i risultati di due controlli Trusted Advisor: Amazon S3 Bucket Permissions e IAM Use.

aws support describe-trusted-advisor-check-summaries \ --check-ids "Pfx0RwqBli" "zXCkfM1nI3"

Output:

{ "summaries": [ { "checkId": "Pfx0RwqBli", "timestamp": "2020-05-13T21:38:12Z", "status": "ok", "hasFlaggedResources": true, "resourcesSummary": { "resourcesProcessed": 44, "resourcesFlagged": 0, "resourcesIgnored": 0, "resourcesSuppressed": 0 }, "categorySpecificSummary": { "costOptimizing": { "estimatedMonthlySavings": 0.0, "estimatedPercentMonthlySavings": 0.0 } } }, { "checkId": "zXCkfM1nI3", "timestamp": "2020-05-13T21:38:05Z", "status": "ok", "hasFlaggedResources": true, "resourcesSummary": { "resourcesProcessed": 1, "resourcesFlagged": 0, "resourcesIgnored": 0, "resourcesSuppressed": 0 }, "categorySpecificSummary": { "costOptimizing": { "estimatedMonthlySavings": 0.0, "estimatedPercentMonthlySavings": 0.0 } } } ] }

Per ulteriori informazioni, consulta AWS Trusted Advisor nella AWS Support User Guide.

Il seguente esempio di codice mostra come utilizzaredescribe-trusted-advisor-checks.

AWS CLI

Per elencare i controlli AWS Trusted Advisor disponibili

L'describe-trusted-advisor-checksesempio seguente elenca gli assegni Trusted Advisor disponibili nell' AWS account. Queste informazioni includono il nome, l'ID, la descrizione, la categoria e i metadati dell'assegno. Nota che l'output è abbreviato per motivi di leggibilità.

aws support describe-trusted-advisor-checks \ --language "en"

Output:

{ "checks": [ { "id": "zXCkfM1nI3", "name": "IAM Use", "description": "Checks for your use of AWS Identity and Access Management (IAM). You can use IAM to create users, groups, and roles in AWS, and you can use permissions to control access to AWS resources. \n<br>\n<br>\n<b>Alert Criteria</b><br>\nYellow: No IAM users have been created for this account.\n<br>\n<br>\n<b>Recommended Action</b><br>\nCreate one or more IAM users and groups in your account. You can then create additional users whose permissions are limited to perform specific tasks in your AWS environment. For more information, see <a href=\"https://docs.aws.amazon.com/IAM/latest/UserGuide/IAMGettingStarted.html\" target=\"_blank\">Getting Started</a>. \n<br><br>\n<b>Additional Resources</b><br>\n<a href=\"https://docs.aws.amazon.com/IAM/latest/UserGuide/IAM_Introduction.html\" target=\"_blank\">What Is IAM?</a>", "category": "security", "metadata": [] } ] }

Per ulteriori informazioni, consulta AWS Trusted Advisor nella AWS Support User Guide.

Il seguente esempio di codice mostra come utilizzarerefresh-trusted-advisor-check.

AWS CLI

Per aggiornare un controllo di AWS Trusted Advisor

L'refresh-trusted-advisor-checkesempio seguente aggiorna il check di Amazon S3 Bucket Permissions Trusted Advisor nel tuo account. AWS

aws support refresh-trusted-advisor-check \ --check-id "Pfx0RwqBli"

Output:

{ "status": { "checkId": "Pfx0RwqBli", "status": "enqueued", "millisUntilNextRefreshable": 3599992 } }

Per ulteriori informazioni, consulta AWS Trusted Advisor nella AWS Support User Guide.

Il seguente esempio di codice mostra come utilizzareresolve-case.

AWS CLI

Per risolvere un caso di assistenza

L'resolve-caseesempio seguente risolve un caso di assistenza nel tuo AWS account.

aws support resolve-case \ --case-id "case-12345678910-2013-c4c1d2bf33c5cf47"

Output:

{ "finalCaseStatus": "resolved", "initialCaseStatus": "work-in-progress" }

Per ulteriori informazioni, consulta la sezione Gestione dei casi nella AWS Support User Guide.