将 DescribeNotificationConfigurations 与 CLI 配合使用 - AWS SDK 代码示例

文档 AWS SDK 示例 GitHub 存储库中还有更多 S AWS DK 示例

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

DescribeNotificationConfigurations 与 CLI 配合使用

以下代码示例演示如何使用 DescribeNotificationConfigurations

CLI
AWS CLI

示例 1:描述指定组的通知配置

此示例描述指定自动扩缩组的通知配置。

aws autoscaling describe-notification-configurations \ --auto-scaling-group-name my-asg

输出:

{ "NotificationConfigurations": [ { "AutoScalingGroupName": "my-asg", "NotificationType": "autoscaling:TEST_NOTIFICATION", "TopicARN": "arn:aws:sns:us-west-2:123456789012:my-sns-topic-2" }, { "AutoScalingGroupName": "my-asg", "NotificationType": "autoscaling:TEST_NOTIFICATION", "TopicARN": "arn:aws:sns:us-west-2:123456789012:my-sns-topic" } ] }

有关更多信息,请参阅 Amazon Auto Scaling 用户指南中的在您的 Auto Scaling 群组扩展时获取 Amazon EC2 SNS 通知

示例 1:描述指定数量的通知配置

要返回特定数量的通知配置,请使用 max-items 参数。

aws autoscaling describe-notification-configurations \ --auto-scaling-group-name my-auto-scaling-group \ --max-items 1

输出:

{ "NotificationConfigurations": [ { "AutoScalingGroupName": "my-asg", "NotificationType": "autoscaling:TEST_NOTIFICATION", "TopicARN": "arn:aws:sns:us-west-2:123456789012:my-sns-topic-2" }, { "AutoScalingGroupName": "my-asg", "NotificationType": "autoscaling:TEST_NOTIFICATION", "TopicARN": "arn:aws:sns:us-west-2:123456789012:my-sns-topic" } ] }

如果输出包含 NextToken 字段,可返回更多通知配置。要获取其他通知配置,请在后续调用中使用此字段的值和 starting-token 选项,如下所示。

aws autoscaling describe-notification-configurations \ --auto-scaling-group-name my-asg \ --starting-token Z3M3LMPEXAMPLE

有关更多信息,请参阅 Amazon Auto Scaling 用户指南中的在您的 Auto Scaling 群组扩展时获取 Amazon EC2 SNS 通知

PowerShell
用于 PowerShell

示例 1:此示例描述与指定自动扩缩组关联的通知操作。

Get-ASNotificationConfiguration -AutoScalingGroupName my-asg | format-list

输出

AutoScalingGroupName : my-asg NotificationType : auto-scaling:EC2_INSTANCE_LAUNCH TopicARN : arn:aws:sns:us-west-2:123456789012:my-topic AutoScalingGroupName : my-asg NotificationType : auto-scaling:EC2_INSTANCE_TERMINATE TopicARN : arn:aws:sns:us-west-2:123456789012:my-topic

示例 2:此示例描述与所有自动扩缩组关联的通知操作。

Get-ASNotificationConfiguration