AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
AWS Health 使用示例 AWS CLI
以下代码示例向您展示了如何使用with来执行操作和实现常见场景 AWS Health。 AWS Command Line Interface
操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。
每个示例都包含一个指向完整源代码的链接,您可以在其中找到有关如何在上下文中设置和运行代码的说明。
主题
操作
以下代码示例演示如何使用 describe-affected-entities
。
- AWS CLI
-
列出受指定 AWS Health 事件影响的实体
以下
describe-affected-entities
示例列出了受指定 AWS Health 事件影响的实体。此事件是该 AWS 账户的账单通知。aws health describe-affected-entities \ --filter
"eventArns=arn:aws:health:global::event/BILLING/AWS_BILLING_NOTIFICATION/AWS_BILLING_NOTIFICATION_6ce1d874-e995-40e2-99cd-EXAMPLE11145"
\ --regionus-east-1
输出:
{ "entities": [ { "entityArn": "arn:aws:health:global:123456789012:entity/EXAMPLEimSMoULmWHpb", "eventArn": "arn:aws:health:global::event/BILLING/AWS_BILLING_NOTIFICATION/AWS_BILLING_NOTIFICATION_6ce1d874-e995-40e2-99cd-EXAMPLE11145", "entityValue": "AWS_ACCOUNT", "awsAccountId": "123456789012", "lastUpdatedTime": 1588356454.08 } ] }
有关更多信息,请参阅 Healt AWS h 用户指南中的事件日志。
-
有关API详细信息,请参阅 “DescribeAffectedEntities AWS CLI
命令参考”。
-
以下代码示例演示如何使用 describe-event-details
。
- AWS CLI
-
列出有关 AWS Health 事件的信息
以下
describe-event-details
示例列出了有关指定 AWS Health 事件的信息。aws health describe-event-details \ --event-arns
"arn:aws:health:us-east-1::event/EC2/AWS_EC2_OPERATIONAL_ISSUE/AWS_EC2_OPERATIONAL_ISSUE_VKTXI_EXAMPLE111"
\ --regionus-east-1
输出:
{ "successfulSet": [ { "event": { "arn": "arn:aws:health:us-east-1::event/EC2/AWS_EC2_OPERATIONAL_ISSUE/AWS_EC2_OPERATIONAL_ISSUE_VKTXI_EXAMPLE111", "service": "EC2", "eventTypeCode": "AWS_EC2_OPERATIONAL_ISSUE", "eventTypeCategory": "issue", "region": "us-east-1", "startTime": 1587462325.096, "endTime": 1587464204.774, "lastUpdatedTime": 1587464204.865, "statusCode": "closed" }, "eventDescription": { "latestDescription": "[RESOLVED] Increased API Error Rates and Latencies\n\n[02:45 AM PDT] We are investigating increased API error rates and latencies in the US-EAST-1 Region.\n\n[03:16 AM PDT] Between 2:10 AM and 2:59 AM PDT we experienced increased API error rates and latencies in the US-EAST-1 Region. The issue has been resolved and the service is operating normally." } } ], "failedSet": [] }
有关更多信息,请参阅 Healt AWS h 用户指南中的事件详情窗格。
-
有关API详细信息,请参阅 “DescribeEventDetails AWS CLI
命令参考”。
-
以下代码示例演示如何使用 describe-events
。
- AWS CLI
-
示例 1:列出 Healt AWS h 事件
以下
describe-events
示例列出了最近的 He AWS alth 事件。aws health describe-events \ --region
us-east-1
输出:
{ "events": [ { "arn": "arn:aws:health:us-west-1::event/ECS/AWS_ECS_OPERATIONAL_ISSUE/AWS_ECS_OPERATIONAL_ISSUE_KWQPY_EXAMPLE111", "service": "ECS", "eventTypeCode": "AWS_ECS_OPERATIONAL_ISSUE", "eventTypeCategory": "issue", "region": "us-west-1", "startTime": 1589077890.53, "endTime": 1589086345.597, "lastUpdatedTime": 1589086345.905, "statusCode": "closed", "eventScopeCode": "PUBLIC" }, { "arn": "arn:aws:health:global::event/BILLING/AWS_BILLING_NOTIFICATION/AWS_BILLING_NOTIFICATION_6ce1d874-e995-40e2-99cd-EXAMPLE1118b", "service": "BILLING", "eventTypeCode": "AWS_BILLING_NOTIFICATION", "eventTypeCategory": "accountNotification", "region": "global", "startTime": 1588356000.0, "lastUpdatedTime": 1588356524.358, "statusCode": "open", "eventScopeCode": "ACCOUNT_SPECIFIC" }, { "arn": "arn:aws:health:us-west-2::event/CLOUDFORMATION/AWS_CLOUDFORMATION_OPERATIONAL_ISSUE/AWS_CLOUDFORMATION_OPERATIONAL_ISSUE_OHTWY_EXAMPLE111", "service": "CLOUDFORMATION", "eventTypeCode": "AWS_CLOUDFORMATION_OPERATIONAL_ISSUE", "eventTypeCategory": "issue", "region": "us-west-2", "startTime": 1588279630.761, "endTime": 1588284650.0, "lastUpdatedTime": 1588284691.941, "statusCode": "closed", "eventScopeCode": "PUBLIC" }, { "arn": "arn:aws:health:ap-northeast-1::event/LAMBDA/AWS_LAMBDA_OPERATIONAL_ISSUE/AWS_LAMBDA_OPERATIONAL_ISSUE_JZDND_EXAMPLE111", "service": "LAMBDA", "eventTypeCode": "AWS_LAMBDA_OPERATIONAL_ISSUE", "eventTypeCategory": "issue", "region": "ap-northeast-1", "startTime": 1587379534.08, "endTime": 1587391771.0, "lastUpdatedTime": 1587395689.316, "statusCode": "closed", "eventScopeCode": "PUBLIC" }, { "arn": "arn:aws:health:us-east-1::event/EC2/AWS_EC2_OPERATIONAL_ISSUE/AWS_EC2_OPERATIONAL_ISSUE_COBXJ_EXAMPLE111", "service": "EC2", "eventTypeCode": "AWS_EC2_OPERATIONAL_ISSUE", "eventTypeCategory": "issue", "region": "us-east-1", "startTime": 1586473044.284, "endTime": 1586479706.091, "lastUpdatedTime": 1586479706.153, "statusCode": "closed", "eventScopeCode": "PUBLIC" }, { "arn": "arn:aws:health:global::event/SECURITY/AWS_SECURITY_NOTIFICATION/AWS_SECURITY_NOTIFICATION_42007387-8129-42da-8c88-EXAMPLE11139", "service": "SECURITY", "eventTypeCode": "AWS_SECURITY_NOTIFICATION", "eventTypeCategory": "accountNotification", "region": "global", "startTime": 1585674000.0, "lastUpdatedTime": 1585674004.132, "statusCode": "open", "eventScopeCode": "PUBLIC" }, { "arn": "arn:aws:health:global::event/CLOUDFRONT/AWS_CLOUDFRONT_OPERATIONAL_ISSUE/AWS_CLOUDFRONT_OPERATIONAL_ISSUE_FRQXG_EXAMPLE111", "service": "CLOUDFRONT", "eventTypeCode": "AWS_CLOUDFRONT_OPERATIONAL_ISSUE", "eventTypeCategory": "issue", "region": "global", "startTime": 1585610898.589, "endTime": 1585617671.0, "lastUpdatedTime": 1585620638.869, "statusCode": "closed", "eventScopeCode": "PUBLIC" }, { "arn": "arn:aws:health:us-east-1::event/SES/AWS_SES_OPERATIONAL_ISSUE/AWS_SES_OPERATIONAL_ISSUE_URNDF_EXAMPLE111", "service": "SES", "eventTypeCode": "AWS_SES_OPERATIONAL_ISSUE", "eventTypeCategory": "issue", "region": "us-east-1", "startTime": 1585342008.46, "endTime": 1585344017.0, "lastUpdatedTime": 1585344355.989, "statusCode": "closed", "eventScopeCode": "PUBLIC" }, { "arn": "arn:aws:health:global::event/IAM/AWS_IAM_OPERATIONAL_NOTIFICATION/AWS_IAM_OPERATIONAL_NOTIFICATION_b6771c34-6ecd-4aea-9d3e-EXAMPLE1117e", "service": "IAM", "eventTypeCode": "AWS_IAM_OPERATIONAL_NOTIFICATION", "eventTypeCategory": "accountNotification", "region": "global", "startTime": 1584978300.0, "lastUpdatedTime": 1584978553.572, "statusCode": "open", "eventScopeCode": "ACCOUNT_SPECIFIC" }, { "arn": "arn:aws:health:ap-southeast-2::event/EC2/AWS_EC2_OPERATIONAL_ISSUE/AWS_EC2_OPERATIONAL_ISSUE_HNGHE_EXAMPLE111", "service": "EC2", "eventTypeCode": "AWS_EC2_OPERATIONAL_ISSUE", "eventTypeCategory": "issue", "region": "ap-southeast-2", "startTime": 1583881487.483, "endTime": 1583885056.785, "lastUpdatedTime": 1583885057.052, "statusCode": "closed", "eventScopeCode": "PUBLIC" } ] }
有关更多信息,请参阅《AWS 健康用户指南》中的 Person AWS al Health Dashboard 入门。
示例 2:按服务和事件状态代码列出 He AWS alth 事件
以下
describe-events
示例列出了事件 AWS 状态已关闭的亚马逊弹性计算云 (AmazonEC2) 的 Health 事件。aws health describe-events \ --filter
"services=EC2,eventStatusCodes=closed"
输出:
{ "events": [ { "arn": "arn:aws:health:us-east-1::event/EC2/AWS_EC2_OPERATIONAL_ISSUE/AWS_EC2_OPERATIONAL_ISSUE_VKTXI_EXAMPLE111", "service": "EC2", "eventTypeCode": "AWS_EC2_OPERATIONAL_ISSUE", "eventTypeCategory": "issue", "region": "us-east-1", "startTime": 1587462325.096, "endTime": 1587464204.774, "lastUpdatedTime": 1587464204.865, "statusCode": "closed", "eventScopeCode": "PUBLIC" }, { "arn": "arn:aws:health:us-east-1::event/EC2/AWS_EC2_OPERATIONAL_ISSUE/AWS_EC2_OPERATIONAL_ISSUE_COBXJ_EXAMPLE111", "service": "EC2", "eventTypeCode": "AWS_EC2_OPERATIONAL_ISSUE", "eventTypeCategory": "issue", "region": "us-east-1", "startTime": 1586473044.284, "endTime": 1586479706.091, "lastUpdatedTime": 1586479706.153, "statusCode": "closed", "eventScopeCode": "PUBLIC" }, { "arn": "arn:aws:health:ap-southeast-2::event/EC2/AWS_EC2_OPERATIONAL_ISSUE/AWS_EC2_OPERATIONAL_ISSUE_HNGHE_EXAMPLE111", "service": "EC2", "eventTypeCode": "AWS_EC2_OPERATIONAL_ISSUE", "eventTypeCategory": "issue", "region": "ap-southeast-2", "startTime": 1583881487.483, "endTime": 1583885056.785, "lastUpdatedTime": 1583885057.052, "statusCode": "closed", "eventScopeCode": "PUBLIC" } ] }
有关更多信息,请参阅《AWS 健康用户指南》中的 Person AWS al Health Dashboard 入门。
-
有关API详细信息,请参阅 “DescribeEvents AWS CLI
命令参考”。
-