Weitere AWS-SDK-Beispiele sind im GitHub-Repository Beispiele für AWS Doc SDKs
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-namemy-asg\ --topic-arnarn:aws:sns:us-west-2:123456789012:my-sns-topic\ --notification-typeautoscaling:TEST_NOTIFICATIONMit 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.
-
Weitere API-Informationen finden Sie unter PutNotificationConfiguration
in der AWS CLI-Befehlsreferenz.
-
- 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"-
Weitere API-Informationen finden Sie unter PutNotificationConfiguration in der AWS -Tools für PowerShell-Cmdlet-Referenz (V4).
-
- 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"-
Weitere API-Informationen finden Sie unter PutNotificationConfiguration in der AWS -Tools für PowerShell-Cmdlet-Referenz (V5).
-