Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
AWS Health contoh menggunakan AWS CLI
Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum dengan menggunakan AWS Command Line Interface with AWS Health.
Tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.
Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.
Topik
Tindakan
Contoh kode berikut menunjukkan cara menggunakandescribe-affected-entities
.
- AWS CLI
-
Untuk membuat daftar entitas yang terpengaruh oleh peristiwa AWS Kesehatan tertentu
describe-affected-entities
Contoh berikut mencantumkan entitas yang terpengaruh oleh peristiwa AWS Kesehatan yang ditentukan. Acara ini adalah pemberitahuan penagihan untuk AWS akun tersebut.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
Output:
{ "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 } ] }
Untuk informasi selengkapnya, lihat Log peristiwa di Panduan Pengguna AWS Kesehatan.
-
Untuk API detailnya, lihat DescribeAffectedEntities
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-event-details
.
- AWS CLI
-
Untuk membuat daftar informasi tentang acara AWS Kesehatan
describe-event-details
Contoh berikut mencantumkan informasi tentang acara AWS Kesehatan yang ditentukan.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
Output:
{ "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": [] }
Untuk informasi selengkapnya, lihat panel Detail acara di Panduan Pengguna AWS Kesehatan.
-
Untuk API detailnya, lihat DescribeEventDetails
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandescribe-events
.
- AWS CLI
-
Contoh 1: Untuk membuat daftar acara AWS Kesehatan
describe-events
Contoh berikut mencantumkan peristiwa AWS Kesehatan terbaru.aws health describe-events \ --region
us-east-1
Output:
{ "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" } ] }
Untuk informasi selengkapnya, lihat Memulai Dashboard AWS Personal AWS Health di Panduan Pengguna Kesehatan.
Contoh 2: Untuk daftar acara AWS Kesehatan berdasarkan layanan dan kode status acara
describe-events
Contoh berikut mencantumkan peristiwa AWS Kesehatan untuk Amazon Elastic Compute Cloud (AmazonEC2) di mana status acara ditutup.aws health describe-events \ --filter
"services=EC2,eventStatusCodes=closed"
Output:
{ "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" } ] }
Untuk informasi selengkapnya, lihat Memulai Dashboard AWS Personal AWS Health di Panduan Pengguna Kesehatan.
-
Untuk API detailnya, lihat DescribeEvents
di Referensi AWS CLI Perintah.
-