Verwendung von PutNotificationConfiguration mit einer CLI - AWS-SDK-Codebeispiele

Weitere AWS-SDK-Beispiele sind im GitHub-Repository Beispiele für AWS Doc SDKs verfügbar.

Verwendung von PutNotificationConfiguration mit einer CLI

Die folgenden Code-Beispiele zeigen, wie PutNotificationConfiguration verwendet wird.

CLI
AWS CLI

So fügen Sie eine neue Benachrichtigung hinzu

In diesem Beispiel wird die angegebene Benachrichtigung der spezifizierten Auto-Scaling-Gruppe hinzugefügt.

aws autoscaling put-notification-configuration \ --auto-scaling-group-name my-asg \ --topic-arn arn:aws:sns:us-west-2:123456789012:my-sns-topic \ --notification-type autoscaling:TEST_NOTIFICATION

Mit diesem Befehl wird keine Ausgabe zurückgegeben.

Weitere Informationen finden Sie unter Abrufen von Amazon-SNS-Benachrichtigungen über Skalierungen einer Auto-Scaling-Gruppe im Amazon-EC2-Auto-Scaling-Benutzerhandbuch.

PowerShell
Tools für PowerShell V4

Beispiel 1: In diesem Beispiel wird die angegebene Auto-Scaling-Gruppe so konfiguriert, dass sie beim Starten von EC2-Instances eine Benachrichtigung an das spezifizierte SNS-Thema sendet.

Write-ASNotificationConfiguration -AutoScalingGroupName my-asg -NotificationType "autoscaling:EC2_INSTANCE_LAUNCH" -TopicARN "arn:aws:sns:us-west-2:123456789012:my-topic"

Beispiel 2: In diesem Beispiel wird die angegebene Auto-Scaling-Gruppe so konfiguriert, dass sie beim Starten oder Beenden von EC2-Instances eine Benachrichtigung an das angegebene SNS-Thema sendet.

Write-ASNotificationConfiguration -AutoScalingGroupName my-asg -NotificationType @("autoscaling:EC2_INSTANCE_LAUNCH", "autoscaling:EC2_INSTANCE_TERMINATE") -TopicARN "arn:aws:sns:us-west-2:123456789012:my-topic"
Tools für PowerShell V5

Beispiel 1: In diesem Beispiel wird die angegebene Auto-Scaling-Gruppe so konfiguriert, dass sie beim Starten von EC2-Instances eine Benachrichtigung an das spezifizierte SNS-Thema sendet.

Write-ASNotificationConfiguration -AutoScalingGroupName my-asg -NotificationType "autoscaling:EC2_INSTANCE_LAUNCH" -TopicARN "arn:aws:sns:us-west-2:123456789012:my-topic"

Beispiel 2: In diesem Beispiel wird die angegebene Auto-Scaling-Gruppe so konfiguriert, dass sie beim Starten oder Beenden von EC2-Instances eine Benachrichtigung an das angegebene SNS-Thema sendet.

Write-ASNotificationConfiguration -AutoScalingGroupName my-asg -NotificationType @("autoscaling:EC2_INSTANCE_LAUNCH", "autoscaling:EC2_INSTANCE_TERMINATE") -TopicARN "arn:aws:sns:us-west-2:123456789012:my-topic"