AWS 文档 SDK 示例
将 PutNotificationConfiguration 与 CLI 配合使用
以下代码示例演示如何使用 PutNotificationConfiguration。
- CLI
-
- AWS CLI
-
添加通知
此示例将指定的通知添加到指定的自动扩缩组。
aws autoscaling put-notification-configuration \ --auto-scaling-group-namemy-asg\ --topic-arnarn:aws:sns:us-west-2:123456789012:my-sns-topic\ --notification-typeautoscaling:TEST_NOTIFICATION此命令不生成任何输出。
有关更多信息,请参阅《Amazon EC2 Auto Scaling 用户指南》中的在自动扩缩组扩展时获取 Amazon SNS 通知。
-
有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 PutNotificationConfiguration
。
-
- PowerShell
-
- Tools for PowerShell V4
-
示例 1:此示例将指定的自动扩缩组配置为在启动 EC2 实例时向指定的 SNS 主题发送通知。
Write-ASNotificationConfiguration -AutoScalingGroupName my-asg -NotificationType "autoscaling:EC2_INSTANCE_LAUNCH" -TopicARN "arn:aws:sns:us-west-2:123456789012:my-topic"示例 2:此示例将指定的自动扩缩组配置为在启动或终止 EC2 实例时向指定的 SNS 主题发送通知。
Write-ASNotificationConfiguration -AutoScalingGroupName my-asg -NotificationType @("autoscaling:EC2_INSTANCE_LAUNCH", "autoscaling:EC2_INSTANCE_TERMINATE") -TopicARN "arn:aws:sns:us-west-2:123456789012:my-topic"-
有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference (V4)》中的 PutNotificationConfiguration。
-
- Tools for PowerShell V5
-
示例 1:此示例将指定的自动扩缩组配置为在启动 EC2 实例时向指定的 SNS 主题发送通知。
Write-ASNotificationConfiguration -AutoScalingGroupName my-asg -NotificationType "autoscaling:EC2_INSTANCE_LAUNCH" -TopicARN "arn:aws:sns:us-west-2:123456789012:my-topic"示例 2:此示例将指定的自动扩缩组配置为在启动或终止 EC2 实例时向指定的 SNS 主题发送通知。
Write-ASNotificationConfiguration -AutoScalingGroupName my-asg -NotificationType @("autoscaling:EC2_INSTANCE_LAUNCH", "autoscaling:EC2_INSTANCE_TERMINATE") -TopicARN "arn:aws:sns:us-west-2:123456789012:my-topic"-
有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference (V5)》中的 PutNotificationConfiguration。
-
PutLifecycleHook
PutScalingPolicy