AWS 文档 SDK 示例
将 DescribeNotificationConfigurations 与 CLI 配合使用
以下代码示例演示如何使用 DescribeNotificationConfigurations。
- CLI
-
- AWS CLI
-
示例 1:描述指定组的通知配置
此示例描述指定自动扩缩组的通知配置。
aws autoscaling describe-notification-configurations \ --auto-scaling-group-namemy-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 EC2 Auto Scaling 用户指南》中的在自动扩缩组扩展时获取 Amazon SNS 通知。
示例 1:描述指定数量的通知配置
要返回特定数量的通知配置,请使用
max-items参数。aws autoscaling describe-notification-configurations \ --auto-scaling-group-namemy-auto-scaling-group\ --max-items1输出:
{ "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-namemy-asg\ --starting-tokenZ3M3LMPEXAMPLE有关更多信息,请参阅《Amazon EC2 Auto Scaling 用户指南》中的在自动扩缩组扩展时获取 Amazon SNS 通知。
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DescribeNotificationConfigurations
。
-
- PowerShell
-
- Tools for PowerShell V4
-
示例 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-
有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference (V4)》中的 DescribeNotificationConfigurations。
-
- Tools for PowerShell V5
-
示例 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-
有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference (V5)》中的 DescribeNotificationConfigurations。
-