搭配使用 DescribeNotificationConfigurations 與 CLI - AWS SDK 程式碼範例

AWS文件開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例。

搭配使用 DescribeNotificationConfigurations 與 CLI

下列程式碼範例示範如何使用 DescribeNotificationConfigurations

CLI
AWS CLI

範例 1:描述指定群組的通知組態

此範例描述指定的 Auto Scaling 群組的通知組態。

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 EC2 Auto Scaling 使用者指南中的取得 Auto Scaling 群組擴展時的 Amazon 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 EC2 Auto Scaling 使用者指南中的取得 Auto Scaling 群組擴展時的 Amazon SNS 通知

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
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