使用 Amazon CLI 的 Amazon Web Services 支持示例 - Amazon Command Line Interface
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

使用 Amazon CLI 的 Amazon Web Services 支持示例

以下代码示例演示了如何通过将 Amazon Command Line Interface与 Amazon Web Services 支持 结合使用,来执行操作和实现常见场景。

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

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

主题

操作

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

Amazon CLI

向集合添加附件

以下 add-attachments-to-set 示例向集合添加一张图片,您可以在账户 Amazon 中为支持案例指定该图片。

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

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

  • 有关 API 详细信息,请参阅《Amazon CLI 命令参考》中的 AddAttachmentsToSet

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

Amazon CLI

向案例添加通信

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

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 }

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

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

Amazon CLI

创建案例

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

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

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

  • 有关 API 详细信息,请参阅《Amazon CLI 命令参考》中的 CreateCase

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

Amazon CLI

描述附件

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

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

输出:

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

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

  • 有关 API 详细信息,请参阅《Amazon CLI 命令参考》中的 DescribeAttachment

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

Amazon CLI

描述案例

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

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

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

  • 有关 API 详细信息,请参阅《Amazon CLI 命令参考》中的 DescribeCases

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

Amazon CLI

描述案例的最新通信

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

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

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

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

Amazon CLI

列出 Amazon 服务和服务类别

以下 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" } ] } ] }

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

  • 有关 API 详细信息,请参阅《Amazon CLI 命令参考》中的 DescribeServices

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

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

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

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

Amazon CLI

列出 Amazon Trusted 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 } ] }

有关更多信息,请参阅《Amazon Support 用户指南》中的 Amazon Trusted Advisor

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

Amazon CLI

列出 Amazon Trusted 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 } ] } }

有关更多信息,请参阅《Amazon Support 用户指南》中的 Amazon Trusted Advisor

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

Amazon CLI

列出 Amazon Trusted 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 } } } ] }

有关更多信息,请参阅《Amazon Support 用户指南》中的 Amazon Trusted Advisor

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

Amazon CLI

列出可用的 Amazon Trusted Advisor 检查

以下 describe-trusted-advisor-checks 示例列出您的 Amazon 账户中可用的 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": [] } ] }

有关更多信息,请参阅《Amazon Support 用户指南》中的 Amazon Trusted Advisor

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

Amazon CLI

刷新 Amazon Trusted Advisor 检查

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

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

输出:

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

有关更多信息,请参阅《Amazon Support 用户指南》中的 Amazon Trusted Advisor

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

Amazon CLI

处理支持案例

以下 resolve-case 示例演示了如何处理您 Amazon 账户中的支持案例。

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

输出:

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

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

  • 有关 API 详细信息,请参阅《Amazon CLI 命令参考》中的 ResolveCase