

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# CLI で `PutNotificationConfiguration` を使用する
<a name="example_auto-scaling_PutNotificationConfiguration_section"></a>

次のサンプルコードは、`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 通知の取得](https://docs.aws.amazon.com/autoscaling/ec2/userguide/ASGettingNotifications.html#as-configure-asg-for-sns)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[PutNotificationConfiguration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/autoscaling/put-notification-configuration.html)」を参照してください。

------
#### [ 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"
```
+  API の詳細については、「*AWS Tools for PowerShell コマンドレットリファレンス (V4)*」の「[PutNotificationConfiguration](https://docs.aws.amazon.com/powershell/v4/reference)」を参照してください。

**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"
```
+  API の詳細については、*AWS Tools for PowerShell コマンドレットリファレンス (V5)* の「[PutNotificationConfiguration](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

------

 AWS SDK 開発者ガイドとコード例の完全なリストについては、「」を参照してください[AWS SDK でのこのサービスの使用](sdk-general-information-section.md)。このトピックには、使用開始方法に関する情報と、以前の SDK バージョンの詳細も含まれています。