D'autres exemples de AWS SDK sont disponibles dans le référentiel AWS Doc SDK Examples
Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
Utilisation de PutNotificationConfiguration
avec une CLI
Les exemples de code suivants illustrent comment utiliser PutNotificationConfiguration
.
- CLI
-
- AWS CLI
-
Pour ajouter une notification
Cet exemple ajoute la notification spécifiée au groupe Auto Scaling spécifié.
aws autoscaling put-notification-configuration \ --auto-scaling-group-name
my-asg
\ --topic-arnarn:aws:sns:us-west-2:123456789012:my-sns-topic
\ --notification-typeautoscaling:TEST_NOTIFICATION
Cette commande ne produit aucun résultat.
Pour plus d'informations, consultez la section Recevoir des notifications Amazon SNS lorsque votre groupe Auto Scaling évolue dans le guide de l'utilisateur d'Amazon EC2 Auto Scaling.
-
Pour plus de détails sur l'API, voir PutNotificationConfiguration
la section Référence des AWS CLI commandes.
-
- PowerShell
-
- Outils pour PowerShell V4
-
Exemple 1 : Cet exemple configure le groupe Auto Scaling spécifié pour envoyer une notification à la rubrique SNS spécifiée lorsqu'il lance EC2 des instances.
Write-ASNotificationConfiguration -AutoScalingGroupName my-asg -NotificationType "autoscaling:EC2_INSTANCE_LAUNCH" -TopicARN "arn:aws:sns:us-west-2:123456789012:my-topic"
Exemple 2 : Cet exemple configure le groupe Auto Scaling spécifié pour envoyer une notification à la rubrique SNS spécifiée lorsqu'il lance ou met fin EC2 à des instances.
Write-ASNotificationConfiguration -AutoScalingGroupName my-asg -NotificationType @("autoscaling:EC2_INSTANCE_LAUNCH", "autoscaling:EC2_INSTANCE_TERMINATE") -TopicARN "arn:aws:sns:us-west-2:123456789012:my-topic"
-
Pour plus de détails sur l'API, reportez-vous PutNotificationConfigurationà la section Référence des Outils AWS pour PowerShell applets de commande (V4).
-
- Outils pour PowerShell V5
-
Exemple 1 : Cet exemple configure le groupe Auto Scaling spécifié pour envoyer une notification à la rubrique SNS spécifiée lorsqu'il lance EC2 des instances.
Write-ASNotificationConfiguration -AutoScalingGroupName my-asg -NotificationType "autoscaling:EC2_INSTANCE_LAUNCH" -TopicARN "arn:aws:sns:us-west-2:123456789012:my-topic"
Exemple 2 : Cet exemple configure le groupe Auto Scaling spécifié pour envoyer une notification à la rubrique SNS spécifiée lorsqu'il lance ou met fin EC2 à des instances.
Write-ASNotificationConfiguration -AutoScalingGroupName my-asg -NotificationType @("autoscaling:EC2_INSTANCE_LAUNCH", "autoscaling:EC2_INSTANCE_TERMINATE") -TopicARN "arn:aws:sns:us-west-2:123456789012:my-topic"
-
Pour plus de détails sur l'API, reportez-vous PutNotificationConfigurationà la section Référence des Outils AWS pour PowerShell applets de commande (V5).
-