AWS文件開發套件範例
搭配使用 DescribeNotificationConfigurations 與 CLI
下列程式碼範例示範如何使用 DescribeNotificationConfigurations。
- CLI
-
- AWS CLI
-
範例 1:描述指定群組的通知組態
此範例描述指定的 Auto Scaling 群組的通知組態。
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 使用者指南中的取得 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 使用者指南中的取得 Auto Scaling 群組擴展時的 Amazon SNS 通知。
-
如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 DescribeNotificationConfigurations
。
-
- PowerShell
-
- Tools for PowerShell V4
-
範例 1:此範例描述與指定的 Auto Scaling 群組相關聯的通知動作。
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:此範例描述與所有 Auto Scaling 群組相關聯的通知動作。
Get-ASNotificationConfiguration-
如需 API 詳細資訊,請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》中的 DescribeNotificationConfigurations。
-
- Tools for PowerShell V5
-
範例 1:此範例描述與指定的 Auto Scaling 群組相關聯的通知動作。
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:此範例描述與所有 Auto Scaling 群組相關聯的通知動作。
Get-ASNotificationConfiguration-
如需 API 詳細資訊,請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》中的 DescribeNotificationConfigurations。
-