

# EC2 インスタンスのスケジュールされたイベント通知をカスタマイズする
<a name="customizing_scheduled_event_notifications"></a>

スケジュールされたイベント通知をカスタマイズして、メール通知にタグを含めることができます。これにより、影響を受けるリソース (インスタンスまたは 専用ホスト) を特定して、その後のイベントに対するアクションに優先順位を付けやすくなります。

タグを含めるようにイベント通知をカスタマイズする場合、次のいずれかを含めることができます。
+ 影響を受けるリソースに関連付けられているすべてのタグ
+ 影響を受けるリソースに関連付けられている特定のタグのみ

例えば、`application`、`costcenter`、`project`、`owner` タグをすべてのインスタンスに割り当てるとします。イベント通知にはこれらのすべてのタグを含めることができます。また、イベント通知に `owner` タグと `project` タグのみを表示したい場合はそれらのタグのみを含めることもできます。

含めるタグを選択すると、イベント通知には影響を受けるリソースに関連付けられているリソース ID (インスタンス ID または Dedicated Host ID) とタグのキーと値のペアが含まれます。

**Topics**
+ [イベント通知にタグを含める](#register-tags)
+ [イベント通知からのタグの削除](#deregister-tags)
+ [イベント通知に含めるタグの表示](#view-tags)

## イベント通知にタグを含める
<a name="register-tags"></a>

含めるように選択したタグは選択したリージョンのすべてのリソース (インスタンスと 専用ホスト) に適用されます。他のリージョンのイベント通知をカスタマイズするにはまず必要なリージョンを選択してから、次の手順を実行します。

------
#### [ Console ]

**イベント通知にタグを含めるには**

1. Amazon EC2 コンソールの [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/) を開いてください。

1. ナビゲーションペインの [**Events**] を選択してください。

1. [**アクション**]、[**Manage event notifications (イベント通知の管理)**] の順に選択してください。

1. **[イベント通知にタグを含める]**をオンにします。

1. イベント通知に含めるタグに応じて、次のいずれかの操作を行います。
   + 影響を受けるインスタンスまたは専有ホストに関連付けられている全タグを含めるには**[全タグを含める]** を選択してください。
   + 含めるタグを選択するには **[含めるタグを選択]** を選択し、タグキーを選択または入力してください。

1. [**Save**] を選択してください。

------
#### [ AWS CLI ]

**イベント通知にすべてのタグを含めるには**  
`IncludeAllTagsOfInstance` コマンドの [register-instance-event-notification-attributes](https://docs.aws.amazon.com/cli/latest/reference/ec2/register-instance-event-notification-attributes.html) を使用して、`true` パラメータをに設定します。

```
aws ec2 register-instance-event-notification-attributes \
    --instance-tag-attribute "IncludeAllTagsOfInstance=true"
```

**イベント通知に特定のタグを含めるには**  
 コマンドの [register-instance-event-notification-attributes](https://docs.aws.amazon.com/cli/latest/reference/ec2/register-instance-event-notification-attributes.html) を使用して、パラメー`InstanceTagKeys` タを使用して含めるタグを指定します。

```
aws ec2 register-instance-event-notification-attributes \
    --instance-tag-attribute 'InstanceTagKeys=["{{tag_key_1}}", "{{tag_key_2}}", "{{tag_key_3}}"]'
```

------
#### [ PowerShell ]

**イベント通知にすべてのタグを含めるには**  
[Register-EC2InstanceEventNotificationAttribute](https://docs.aws.amazon.com/powershell/latest/reference/items/Register-EC2InstanceEventNotificationAttribute.html) コマンドレットを使用します。

```
Register-EC2InstanceEventNotificationAttribute `
    -InstanceTagAttribute_IncludeAllTagsOfInstance $true
```

**イベント通知に特定のタグを含めるには**  
[Register-EC2InstanceEventNotificationAttribute](https://docs.aws.amazon.com/powershell/latest/reference/items/Register-EC2InstanceEventNotificationAttribute.html) コマンドレットを使用します。

```
Register-EC2InstanceEventNotificationAttribute `
    -InstanceTagAttribute_InstanceTagKey {{tag_key_1}}, {{tag_key_2}}, {{tag_key_3}}
```

------

## イベント通知からのタグの削除
<a name="deregister-tags"></a>

イベント通知からタグを削除できます。

------
#### [ Console ]

**イベント通知からタグを削除するには**

1. Amazon EC2 コンソールの [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/) を開いてください。

1. ナビゲーションペインの [**Events**] を選択してください。

1. [**アクション**]、[**Manage event notifications (イベント通知の管理)**] の順に選択してください。

1. イベント通知からすべてのタグを削除するには**[イベント通知にタグを含める]** をオフにします。

1. イベント通知から特定のタグを削除するには対応するタグキーの [**X**] を選択してください。

1. [**Save**] を選択してください。

------
#### [ AWS CLI ]

**イベント通知からすべてのタグを削除するには**  
`IncludeAllTagsOfInstance` コマンドの [deregister-instance-event-notification-attributes](https://docs.aws.amazon.com/cli/latest/reference/ec2/deregister-instance-event-notification-attributes.html) を使用して、`false` パラメータをに設定します。

```
aws ec2 deregister-instance-event-notification-attributes \
    --instance-tag-attribute "IncludeAllTagsOfInstance=false"
```

**イベント通知からタグを削除するには**  
 コマンドの [deregister-instance-event-notification-attributes](https://docs.aws.amazon.com/cli/latest/reference/ec2/deregister-instance-event-notification-attributes.html) を使用して、パラメ`InstanceTagKeys`タを使用して削除するタグを指定します。

```
aws ec2 deregister-instance-event-notification-attributes \
    --instance-tag-attribute 'InstanceTagKeys=["{{tag_key_3}}"]'
```

------
#### [ PowerShell ]

**イベント通知からすべてのタグを削除するには**  
[Unregister-EC2InstanceEventNotificationAttribute](https://docs.aws.amazon.com/powershell/latest/reference/items/Unregister-EC2InstanceEventNotificationAttribute.html) コマンドレットを使用します。

```
Unregister-EC2InstanceEventNotificationAttribute `
    -InstanceTagAttribute_IncludeAllTagsOfInstance $false
```

**イベント通知からタグを削除するには**  
[Unregister-EC2InstanceEventNotificationAttribute](https://docs.aws.amazon.com/powershell/latest/reference/items/Unregister-EC2InstanceEventNotificationAttribute.html) コマンドレットを使用します。

```
Unregister-EC2InstanceEventNotificationAttribute `
    -InstanceTagAttribute_InstanceTagKey {{tag_key_3}}
```

------

## イベント通知に含めるタグの表示
<a name="view-tags"></a>

イベント通知に含めるタグを表示できます。

------
#### [ Console ]

**イベント通知に含めるタグを表示するには**

1. Amazon EC2 コンソールの [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/) を開いてください。

1. ナビゲーションペインの [**Events**] を選択してください。

1. [**アクション**]、[**Manage event notifications (イベント通知の管理)**] の順に選択してください。

------
#### [ AWS CLI ]

**イベント通知に含めるタグを表示するには**  
 コマンドの [describe-instance-event-notification-attributes](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instance-event-notification-attributes.html) を使用します。

```
aws ec2 describe-instance-event-notification-attributes
```

------
#### [ PowerShell ]

**イベント通知に含めるタグを表示するには**  
[Get-EC2InstanceEventNotificationAttribute](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2InstanceEventNotificationAttribute.html) コマンドレットを使用します。

```
Get-EC2InstanceEventNotificationAttribute
```

------