CLI로 PutNotificationConfiguration 사용 - AWS SDK 코드 예제

AWS SDK 예제 GitHub 리포지토리에 더 많은 AWS문서 SDK 예제가 있습니다.

CLI로 PutNotificationConfiguration 사용

다음 코드 예시는 PutNotificationConfiguration의 사용 방법을 보여 줍니다.

CLI
AWS CLI

알림을 추가하려면

이 예제에서는 지정된 Auto Scaling 그룹에 지정된 알림을 추가합니다.

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

이 명령은 출력을 생성하지 않습니다.

자세한 정보는 Amazon EC2 Auto Scaling 사용 설명서에서 Auto Scaling 그룹 조정 시 Amazon SNS 알림 수신을 참조하세요.

PowerShell
Tools for PowerShell V4

예제 1: 이 예제에서는 지정된 Auto Scaling 그룹이 EC2 인스턴스를 시작할 때 지정된 SNS 주제에 알림을 보내도록 구성합니다.

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

예제 2: 이 예제에서는 지정된 Auto Scaling 그룹이 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"
Tools for PowerShell V5

예제 1: 이 예제에서는 지정된 Auto Scaling 그룹이 EC2 인스턴스를 시작할 때 지정된 SNS 주제에 알림을 보내도록 구성합니다.

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

예제 2: 이 예제에서는 지정된 Auto Scaling 그룹이 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"