AWS Support 使用示例 AWS CLI - AWS Command Line Interface

本文档 AWS CLI 仅适用于版本 1。有关版本 2 的文档 AWS CLI,请参阅版本 2 用户指南

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

AWS Support 使用示例 AWS CLI

以下代码示例向您展示了如何使用with来执行操作和实现常见场景 AWS Support。 AWS Command Line Interface

操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接,您可以在其中找到有关如何在上下文中设置和运行代码的说明。

主题

操作

以下代码示例显示了如何使用add-attachments-to-set

AWS CLI

向集合中添加附件

以下add-attachments-to-set示例向一组图片添加了一张图片,然后您可以为 AWS 账户中的支持案例指定该图片。

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

输出:

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

有关更多信息,请参阅《AWS Support 用户指南》中的案例管理

以下代码示例显示了如何使用add-communication-to-case

AWS CLI

为案例添加沟通

以下add-communication-to-case示例将通信添加到您 AWS 账户中的支持案例中。

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"

输出:

{ "result": true }

有关更多信息,请参阅《AWS Support 用户指南》中的案例管理

以下代码示例显示了如何使用create-case

AWS CLI

创建案例

以下create-case示例为您的 AWS 账户创建了一个支持案例。

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"

输出:

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

有关更多信息,请参阅《AWS Support 用户指南》中的案例管理

以下代码示例显示了如何使用describe-attachment

AWS CLI

描述附件

以下 describe-attachment 示例返回有关带指定 ID 的附件的信息。

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

输出:

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

有关更多信息,请参阅《AWS Support 用户指南》中的案例管理

以下代码示例显示了如何使用describe-cases

AWS CLI

描述案例

以下describe-cases示例返回有关您 AWS 账户中指定支持案例的信息。

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

输出:

{ "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" } ] }

有关更多信息,请参阅《AWS Support 用户指南》中的案例管理

以下代码示例显示了如何使用describe-communications

AWS CLI

描述案例的最新通信

以下describe-communications示例返回您 AWS 账户中指定支持案例的最新通信。

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

输出:

{ "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==" }

有关更多信息,请参阅《AWS Support 用户指南》中的案例管理

以下代码示例显示了如何使用describe-services

AWS CLI

列出 AWS 服务和服务类别

以下 describe-services 示例列出了用于请求一般信息的可用服务类别。

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

输出:

{ "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" } ] } ] }

有关更多信息,请参阅《AWS Support 用户指南》中的案例管理

以下代码示例显示了如何使用describe-severity-levels

AWS CLI

列出可用的严重性级别

以下 describe-severity-levels 示例列出了支持案例的可用严重性级别。

aws support describe-severity-levels

输出:

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

有关更多信息,请参阅《AWS Support 用户指南》中的选择严重性

以下代码示例显示了如何使用describe-trusted-advisor-check-refresh-statuses

AWS CLI

列出 Truste AWS d Advisor 检查的刷新状态

以下describe-trusted-advisor-check-refresh-statuses示例列出了两个 Trusted Advisor 检查的刷新状态:Amazon S3 存储桶权限和IAM使用。

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

输出:

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

有关更多信息,请参阅《AWS 支持用户指南》中的 T AWS rusted Advisor

以下代码示例显示了如何使用describe-trusted-advisor-check-result

AWS CLI

列出 Tru AWS sted Advisor 检查的结果

以下describe-trusted-advisor-check-result示例列出了 “IAM使用” 检查的结果。

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

输出:

{ "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 } ] } }

有关更多信息,请参阅《AWS 支持用户指南》中的 T AWS rusted Advisor

以下代码示例显示了如何使用describe-trusted-advisor-check-summaries

AWS CLI

列出 Tru AWS sted Advisor 支票摘要

以下describe-trusted-advisor-check-summaries示例列出了两项 Trusted Advisor 检查的结果:Amazon S3 存储桶权限和IAM使用。

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

输出:

{ "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 } } } ] }

有关更多信息,请参阅《AWS 支持用户指南》中的 T AWS rusted Advisor

以下代码示例显示了如何使用describe-trusted-advisor-checks

AWS CLI

列出可用的 T AWS rusted Advisor 支票

以下describe-trusted-advisor-checks示例列出了您 AWS 账户中可用的 Trusted Advisor 支票。这些信息包括支票名称、ID、描述、类别和元数据。请注意,为了便于阅读,输出被缩短了。

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

输出:

{ "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": [] } ] }

有关更多信息,请参阅《AWS 支持用户指南》中的 T AWS rusted Advisor

以下代码示例显示了如何使用refresh-trusted-advisor-check

AWS CLI

刷新 Tru AWS sted Advisor 支票

以下refresh-trusted-advisor-check示例刷新了您 AWS 账户中的 Amazon S3 存储桶权限 Trusted Advisor 支票。

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

输出:

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

有关更多信息,请参阅《AWS 支持用户指南》中的 T AWS rusted Advisor

以下代码示例显示了如何使用resolve-case

AWS CLI

处理支持案例

以下resolve-case示例解决了您 AWS 账户中的一个支持案例。

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

输出:

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

有关更多信息,请参阅《AWS Support 用户指南》中的案例管理