

# Scheduled events for Amazon EC2 instances
Scheduled events

To ensure infrastructure reliability and performance, AWS can schedule events to reboot, stop, and retire your instances. These events do not occur frequently.

If one of your instances will be affected by a scheduled event, AWS notifies you in advance by email, using the email address that's associated with your AWS account. The email provides details about the event, such as the start and end dates. Depending on the event type, you might be able to take action to control the timing of the event. AWS also sends an AWS Health event, which you can monitor and manage by using Amazon EventBridge. For more information, see [Monitoring events in AWS Health with Amazon EventBridge](https://docs.aws.amazon.com/health/latest/ug/cloudwatch-events-health.html). 

Scheduled events are managed by AWS. You can't schedule events for your instances. However, you can:
+ View scheduled events for your instances.
+ Customize scheduled event notifications to include or remove tags from the email notification.
+ Reschedule certain scheduled events.
+ Create custom event windows for scheduled events.
+ Take action when an instance is scheduled to reboot, stop, or retire.

To ensure that you receive notifications of scheduled events, verify your contact information on the [Account](https://console.aws.amazon.com/billing/home?#/account) page.

**Note**  
When an instance is affected by a scheduled event, and it is part of an Auto Scaling group, Amazon EC2 Auto Scaling eventually replaces it as part of its health checks, with no further action necessary on your part. For more information about the health checks performed by Amazon EC2 Auto Scaling, see [Health checks for instances in an Auto Scaling group](https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-health-checks.html) in the *Amazon EC2 Auto Scaling User Guide*.

## Types of scheduled events


Amazon EC2 can create the following types of scheduled events for your instances, where the event occurs at a scheduled time:


| Event type | Event code | Event action | 
| --- | --- | --- | 
| Instance stop | instance-stop | At the scheduled time, the instance is stopped. When you start it again, it's migrated to a new host. Applies only to instances with an Amazon EBS root volume. | 
| Instance retirement | instance-retirement | At the scheduled time, the instance is stopped if it has an Amazon EBS root volume, or terminated if it has an instance store root volume. | 
| Instance reboot | instance-reboot | At the scheduled time, the instance is rebooted. The instance stays on the host, and during the reboot, the host undergoes maintenance. This is known as an in-place reboot. | 
| System reboot | system-reboot | At the scheduled time, the instance is rebooted and migrated to a new host. This is known as a reboot migration. | 
| System maintenance | system-maintenance | At the scheduled time, the instance might be temporarily affected by network maintenance or power maintenance. | 

## Determine the event type


You can check what type of event is scheduled for your instance.

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

**To determine the event type**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Events**.

1. In the table, the event code appears in the **Event type** column.

1. To filter the table to show only the events for instances, in the search field choose **Resource type: instance** from the filter list.

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

**To determine the event type for an instance**  
Use the [describe-instance-status](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instance-status.html) command. If the instance has an associated scheduled event, the output provides information about the scheduled event.

```
aws ec2 describe-instance-status \
    --instance-id i-1234567890abcdef0 \
    --query InstanceStatuses[].Events
```

The following is example output. The scheduled event code is `system-reboot`.

```
[
    "Events": [
        {
            "InstanceEventId": "instance-event-0d59937288b749b32",
            "Code": "system-reboot",
            "Description": "The instance is scheduled for a reboot",
            "NotAfter": "2020-03-14T22:00:00.000Z",
            "NotBefore": "2020-03-14T20:00:00.000Z",
            "NotBeforeDeadline": "2020-04-05T11:00:00.000Z"
        }
    ]
]
```

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

**To determine the event type for an instance**  
Use the [Get-EC2InstanceStatus](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2InstanceStatus.html) cmdlet. If the instance has an associated scheduled event, the output provides information about the scheduled event.

```
(Get-EC2InstanceStatus `
    -InstanceId i-1234567890abcdef0).Events
```

The following is example output. The scheduled event code is `system-reboot`.

```
Code              : system-reboot
Description       : The instance is scheduled for a reboot
InstanceEventId   : instance-event-0d59937288b749b32
NotAfter          : 2020-03-14T22:00:00.000Z
NotBefore         : 2020-03-14T20:00:00.000Z
NotBeforeDeadline : 2020-04-05T11:00:00.000Z
```

------

**Topics**
+ [

## Types of scheduled events
](#types-of-scheduled-events)
+ [

## Determine the event type
](#scheduled-event-type)
+ [

# Manage Amazon EC2 instances scheduled to stop or retire
](schedevents_actions_retire.md)
+ [

# Manage Amazon EC2 instances scheduled for reboot
](schedevents_actions_reboot.md)
+ [

# Manage Amazon EC2 instances scheduled for maintenance
](schedevents_actions_maintenance.md)
+ [

# View scheduled events that affect your Amazon EC2 instances
](viewing_scheduled_events.md)
+ [

# Customize scheduled event notifications for your EC2 instances
](customizing_scheduled_event_notifications.md)
+ [

# Reschedule a scheduled event for an EC2 instance
](reschedule-event.md)
+ [

# Create custom event windows for scheduled events that affect your Amazon EC2 instances
](event-windows.md)

# Manage Amazon EC2 instances scheduled to stop or retire
Manage instances scheduled to stop or retire

When AWS detects irreparable failure of the underlying host for your instance, it schedules the instance to either stop or terminate, depending on the instance's root volume type.
+ If the instance has an Amazon EBS root volume, the instance is scheduled to stop.
+ If the instance has an instance store root volume, the instance is scheduled to terminate.

For more information, see [Instance retirement](instance-retirement.md).

**Important**  
Any data stored on instance store volumes is lost when an instance is stopped, hibernated, or terminated. This includes instance store volumes that are attached to an instance that has an EBS root volume. Be sure to save data from your instance store volumes that you might need later before the instance is stopped, hibernated, or terminated.

## Actions you can take


**Actions you can take for instances with an EBS root volume**

When you receive a scheduled `instance-stop` event notification, you can take one of the following actions:
+ **Wait for scheduled stop:** You can wait for the instance to stop within its scheduled maintenance window.
+ **Perform manual stop and start:** You can stop and start the instance yourself at a time that suits you, which migrates it to a new host. This is not the same as rebooting the instance. For more information, see [Stop and start Amazon EC2 instances](Stop_Start.md).
+ **Automate stop and start:** You can automate an immediate stop and start in response to a scheduled `instance-stop` event. For more information, see [Running operations on EC2 instances automatically in response to events in AWS Health](https://docs.aws.amazon.com/health/latest/ug/automating-instance-actions.html) in the *AWS Health User Guide*.

**Actions you can take for instances with an instance store root volume**

When you receive a scheduled `system-retirement` event notification, and you want to retain your data, you can take the following actions:

1. Launch a replacement instance from your most recent AMI.

1. Migrate all necessary data to the replacement instance before the instance is scheduled to terminate.

1. Terminate the original instance, or wait for it to terminate as scheduled.

For more information about the actions you can take, see [Instance retirement](instance-retirement.md).

# Manage Amazon EC2 instances scheduled for reboot
Manage instances scheduled for reboot

When AWS must perform tasks such as installing updates or maintaining the underlying host, it can schedule an instance reboot. During the scheduled reboot, the instance either stays on the same host, or migrates to a different host, depending on the event, as follows:
+ `instance-reboot` event
  + During the reboot, the instance remains on the host. This is known as an *in-place reboot*.
  + The current host undergoes maintenance. 
  + Typically completes in seconds.
+ `system-reboot` event
  + During the reboot, the instance is migrated to a new host. This is known as a *reboot migration*.
  + Typically completes in minutes.

To check what type of event is scheduled for your instance, see [Determine the event type](monitoring-instances-status-check_sched.md#scheduled-event-type).

## Actions you can take


When you receive a scheduled `instance-reboot` or `system-reboot` event notification, you can take one of the following actions:
+ **Wait for scheduled reboot:** You can wait for the instance reboot to occur within its scheduled maintenance window.
+ **Reschedule the reboot:** You can [reschedule](reschedule-event.md) the instance reboot to a date and time that suits you.
+ **Perform a user-initiated reboot:** You can manually [reboot](ec2-instance-reboot.md) the instance yourself at a time that suits you. However, the outcome depends on the event:
  + `instance-reboot` event – Your instance remains on the current hardware (in-place reboot), no host maintenance takes place, and the event stays open.
  + `system-reboot` event
    + If reboot migration is enabled on your instance, a user-initiated reboot attempts to migrate your instance to new hardware. If successful, the event is cleared. If unsuccessful, an in-place reboot occurs and the event remains scheduled.
    + If reboot migration is disabled on your instance, a user-initiated reboot keeps the instance on the same hardware (in-place reboot), no host maintenance takes place, and the event remains scheduled. When the scheduled event eventually takes place, AWS will move your instance to new hardware (reboot migration).

**After AWS reboots your instance**

The following applies after AWS reboots your instance:
+ The scheduled event is cleared.
+ The event description is updated.
+ For an `instance-reboot` event:
  + Maintenance of the underlying host is complete.
+ For a `system-reboot` event:
  + The instance moves to a new host.
  + The instance retains its IP address and DNS name.
  + Any data on local instance store volumes is preserved.
+ You can use your instance after it has fully booted.

**Alternative options**

If you can't reschedule the reboot event or enable reboot migration for a user-initiated reboot, but want to maintain normal operation during the scheduled maintenance window, you can do the following:
+ **For an instance with an EBS root volume**
  + Manually stop and start the instance to migrate it to a new host. This is not the same as manually rebooting the instance, where the instance stays on the same host.
  + Optionally, automate an immediate instance stop and start in response to the scheduled reboot event. For more information, see [Running operations on EC2 instances automatically in response to events in AWS Health](https://docs.aws.amazon.com/health/latest/ug/automating-instance-actions.html) in the *AWS Health User Guide*.
**Important**  
The data on instance store volumes is lost when an instance is stopped. For more information, see [Stop and start Amazon EC2 instances](Stop_Start.md).
+ **For an instance with an instance store root volume**

  1. Launch a replacement instance from your most recent AMI.

  1. Migrate all necessary data to the replacement instance before the scheduled maintenance window.

  1. Terminate the original instance.

## Enable or disable reboot migration


When an instance is scheduled for a `system-reboot` event, you can reboot it before the event. The outcome of a user-initiated reboot depends on the instance's reboot migration setting:
+ Enabled – A user-initiated reboot attempts to migrate your instance to new hardware (reboot migration). If successful, the event is cleared. If unsuccessful, an in-place reboot occurs and the event remains scheduled. Note that even when enabled, reboot migration can only occur if your instance meets the [reboot migration requirements](#requirements-for-reboot-migration).
+ Disabled – A user-initiated reboot keeps the instance on the same hardware (in-place reboot), no host maintenance takes place, and the event remains scheduled. When the scheduled event eventually takes place, AWS will move your instance to new hardware (reboot migration).

A reboot with migration takes longer than an in-place reboot:
+ In-place reboot: Approximately 30 seconds
+ Reboot with migration: Several minutes

**Note**  
Instances that receive a `system-reboot` event notification are enabled for user-initiated reboot migration by default.

### Requirements for enabling reboot migration


Reboot migration can be enabled on instances that meet the following criteria:

**Instance types**  
Not all instance types support enabling reboot migration. You can view the instance types that support enabling reboot migration.  

**To view the instance types that support enabling reboot migration**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the left navigation pane, choose **Instance Types**.

1. In the filter bar, enter **Reboot Migration support: supported**. As you enter the characters and the filter name appears, you can select it.

   The **Instance types** table displays all the instance types that support enabling reboot migration.
**To view the instance types that support enabling reboot migration**  
Use the [describe-instance-types](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instance-types.html) command with the `reboot-migration-support` filter.

```
aws ec2 describe-instance-types \
    --filters Name=reboot-migration-support,Values=supported \
    --query "InstanceTypes[*].[InstanceType]" \
    --output text | sort
```
**To view the instance types that support enabling reboot migration**  
Use the [Get-EC2InstanceType](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2InstanceType.html) cmdlet with the `reboot-migration-support` filter.

```
Get-EC2InstanceType `
    -Filter @{Name="reboot-migration-support";Values="true"} | `
    Select InstanceType | Sort-Object InstanceType
```

**Tenancy**  
+ Shared
+ Dedicated Instance
For more information, see [Amazon EC2 Dedicated Instances](dedicated-instance.md).

**Limitations**

Reboot migration is **not** supported for instances with the following characteristics:
+ Platform: Instances running natively on the Xen hypervisor
+ Instance size: `metal` instances
+ Tenancy: Dedicated Host. For Dedicated Hosts, use [Dedicated Host Auto Recovery](dedicated-hosts-recovery.md) instead.
+ Storage: Instances with instance store volumes
+ Networking: Instances using an Elastic Fabric Adapter
+ Auto Scaling: Instances that are part of an Auto Scaling group

### Steps for enabling or disabling reboot migration


When an instance receives a `system-reboot` event, it is enabled for reboot migration by default. You can disable reboot migration so that during a user-initiated reboot, the instance stays on the same hardware (in-place reboot).

The `default` configuration doesn't enable reboot migration for an unsupported instance. For more information, see [Requirements for enabling reboot migration](#requirements-for-reboot-migration).

You can disable or enable reboot migration on a running or stopped instance.

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

**To disable reboot migration**  
Use the [modify-instance-maintenance-options](https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-instance-maintenance-options.html) command and set the `--reboot-migration` parameter to `disabled`.

```
aws ec2 modify-instance-maintenance-options \ 
    --instance-id i-0abcdef1234567890 \ 
    --reboot-migration disabled
```

**To enable reboot migration**  
Use the [modify-instance-maintenance-options](https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-instance-maintenance-options.html) command and set the `--reboot-migration` parameter to `default`.

```
aws ec2 modify-instance-maintenance-options \ 
    --instance-id i-0abcdef1234567890 \ 
    --reboot-migration default
```

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

**To disable reboot migration**  
Use the [Edit-EC2InstanceMaintenanceOption](https://docs.aws.amazon.com/powershell/latest/reference/items/Edit-EC2InstanceMaintenanceOption.html) cmdlet.

```
Edit-EC2InstanceMaintenanceOption `
    -InstanceId  `
    -RebootMigration Disabled
```

**To enable reboot migration**  
Use the [Edit-EC2InstanceMaintenanceOption](https://docs.aws.amazon.com/powershell/latest/reference/items/Edit-EC2InstanceMaintenanceOption.html) cmdlet.

```
Edit-EC2InstanceMaintenanceOption `
    -InstanceId i-1234567890abcdef0 `
    -RebootMigration Enabled
```

------

# Manage Amazon EC2 instances scheduled for maintenance
Manage instances scheduled for maintenance

When AWS must maintain the underlying host for an instance, it schedules the instance for maintenance. There are two types of maintenance events: network maintenance and power maintenance.
+ During network maintenance, scheduled instances lose network connectivity for a brief period of time. Normal network connectivity to your instance is restored after maintenance is complete.
+ During power maintenance, scheduled instances are taken offline for a brief period, and then rebooted. When a reboot is performed, all of your instance's configuration settings are retained.

After your instance has rebooted (this normally takes a few minutes), verify that your application is working as expected. At this point, your instance should no longer have a scheduled event associated with it, or if it does, the description of the scheduled event begins with **[Completed]**. It sometimes takes up to 1 hour for the instance status description to refresh. Completed maintenance events are displayed on the Amazon EC2 console dashboard for up to a week.

## Actions you can take


**Actions you can take for instances with an EBS root volume**

When you receive a `system-maintenance` event notification, you can take one of the following actions:
+ **Wait for scheduled maintenance:** You can wait for the maintenance to occur as scheduled.
+ **Perform manual stop and stop:** You can stop and start the instance, which migrates it to a new host. This is not the same as rebooting the instance. For more information, see [Stop and start Amazon EC2 instances](Stop_Start.md).
+ **Automate stop and start:** You can automate an immediate stop and start in response to a scheduled maintenance event. For more information, see [Running operations on EC2 instances automatically in response to events in AWS Health](https://docs.aws.amazon.com/health/latest/ug/automating-instance-actions.html) in the *AWS Health User Guide*.

**Actions you can take for instances with an instance store root volume**

When you receive a `system-maintenance` event notification, you can take one of the following actions:
+ **Wait for scheduled maintenance:** You can wait for the maintenance to occur as scheduled.
+ **Launch a replacement instance:** If you want to maintain normal operation during the scheduled maintenance window:

  1. Launch a replacement instance from your most recent AMI.

  1. Migrate all necessary data to the replacement instance before the scheduled maintenance window.

  1. Terminate the original instance.

# View scheduled events that affect your Amazon EC2 instances
View scheduled events

In addition to receiving notification of scheduled events in email, you can check for scheduled events.

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

**To view scheduled events for your instances**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. The dashboard displays any resources with an associated event under **Scheduled events**.  
![\[Viewing events using the dashboard.\]](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/images/dashboard-scheduled-events.png)

1. For more detail, choose **Events** in the navigation pane. Any resources with an associated event are displayed. You can filter by characteristics such as event type, resource type, and Availability Zone.  
![\[Viewing events using the Events page.\]](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/images/events-instance-scheduled-stop.png)

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

**To view scheduled events for your instances**  
Use the [describe-instance-status](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instance-status.html) command.

```
aws ec2 describe-instance-status \
    --instance-id i-1234567890abcdef0 \
    --query "InstanceStatuses[].Events"
```

The following example output shows a reboot event.

```
[
    "Events": [
        {
            "InstanceEventId": "instance-event-0d59937288b749b32",
            "Code": "system-reboot",
            "Description": "The instance is scheduled for a reboot",
            "NotAfter": "2019-03-15T22:00:00.000Z",
            "NotBefore": "2019-03-14T20:00:00.000Z",
            "NotBeforeDeadline": "2019-04-05T11:00:00.000Z"
         }

    ]
]
```

The following example output shows an instance retirement event.

```
[
    "Events": [
        {
            "InstanceEventId": "instance-event-0e439355b779n26",                        
            "Code": "instance-stop",
            "Description": "The instance is running on degraded hardware",
            "NotBefore": "2015-05-23T00:00:00.000Z"
        }
    ]
]
```

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

**To view scheduled events for your instances**  
Use the following [Get-EC2InstanceStatus](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2InstanceStatus.html) command.

```
(Get-EC2InstanceStatus -InstanceId i-1234567890abcdef0).Events
```

The following example output shows an instance retirement event.

```
Code         : instance-stop
Description  : The instance is running on degraded hardware
NotBefore    : 5/23/2015 12:00:00 AM
```

------
#### [ Instance metadata ]

**To view scheduled events for your instances using instance metadata**  
You can retrieve information about active maintenance events for your instances from the [instance metadata](ec2-instance-metadata.md) by using Instance Metadata Service Version 2 or Instance Metadata Service Version 1.

**IMDSv2**

```
[ec2-user ~]$ TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` \
&& curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/events/maintenance/scheduled
```

**IMDSv1**

```
[ec2-user ~]$ curl http://169.254.169.254/latest/meta-data/events/maintenance/scheduled
```

The following is example output with information about a scheduled system reboot event, in JSON format.

```
[ 
  {
    "NotBefore" : "21 Jan 2019 09:00:43 GMT",
    "Code" : "system-reboot",
    "Description" : "scheduled reboot",
    "EventId" : "instance-event-0d59937288b749b32",
    "NotAfter" : "21 Jan 2019 09:17:23 GMT",
    "State" : "active"
  } 
]
```

**To view event history about completed or canceled events for your instances using instance metadata**  
You can retrieve information about completed or canceled events for your instances from [instance metadata](ec2-instance-metadata.md) by using Instance Metadata Service Version 2 or Instance Metadata Service Version 1.

**IMDSv2**

```
[ec2-user ~]$ TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` \
&& curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/events/maintenance/history
```

**IMDSv1**

```
[ec2-user ~]$ curl http://169.254.169.254/latest/meta-data/events/maintenance/history
```

The following is example output with information about a system reboot event that was canceled, and a system reboot event that was completed, in JSON format.

```
[ 
  {
    "NotBefore" : "21 Jan 2019 09:00:43 GMT",
    "Code" : "system-reboot",
    "Description" : "[Canceled] scheduled reboot",
    "EventId" : "instance-event-0d59937288b749b32",
    "NotAfter" : "21 Jan 2019 09:17:23 GMT",
    "State" : "canceled"
  }, 
  {
    "NotBefore" : "29 Jan 2019 09:00:43 GMT",
    "Code" : "system-reboot",
    "Description" : "[Completed] scheduled reboot",
    "EventId" : "instance-event-0d59937288b749b32",
    "NotAfter" : "29 Jan 2019 09:17:23 GMT",
    "State" : "completed"
  }
]
```

------
#### [ AWS Health ]

You can use the AWS Health Dashboard to learn about events that can affect your instance. The Health Dashboard organizes issues in three groups: open issues, scheduled changes, and other notifications. The scheduled changes group contains items that are ongoing or upcoming.

For more information, see [Getting started with your AWS Health Dashboard](https://docs.aws.amazon.com/health/latest/ug/getting-started-health-dashboard.html) in the *AWS Health User Guide*.

------

# Customize scheduled event notifications for your EC2 instances
Customize scheduled event notifications

You can customize scheduled event notifications to include tags in the email notification. This makes it easier to identify the affected resource (instances or Dedicated Hosts) and to prioritize actions for the upcoming event.

When you customize event notifications to include tags, you can choose to include:
+ All of the tags that are associated with the affected resource
+ Only specific tags that are associated with the affected resource

For example, suppose that you assign `application`, `costcenter`, `project`, and `owner` tags to all of your instances. You can choose to include all of the tags in event notifications. Alternatively, if you'd like to see only the `owner` and `project` tags in event notifications, then you can choose to include only those tags.

After you select the tags to include, the event notifications will include the resource ID (instance ID or Dedicated Host ID) and the tag key and value pairs that are associated with the affected resource.

**Topics**
+ [

## Include tags in event notifications
](#register-tags)
+ [

## Remove tags from event notifications
](#deregister-tags)
+ [

## View the tags to be included in event notifications
](#view-tags)

## Include tags in event notifications


The tags that you choose to include apply to all resources (instances and Dedicated Hosts) in the selected Region. To customize event notifications in other Regions, first select the required Region and then perform the following steps.

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

**To include tags in event notifications**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Events**.

1. Choose **Actions**, **Manage event notifications**.

1. Turn on **Include tags in event notifications**.

1. Do one of the following, depending on the tags that you want to include in event notifications:
   + To include all tags associated with the affected instance or Dedicated Host, select **Include all tags**.
   + To select the tags to include, select **Choose the tags to include** and then select or enter the tag keys.

1. Choose **Save**.

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

**To include all tags in event notifications**  
Use the [register-instance-event-notification-attributes](https://docs.aws.amazon.com/cli/latest/reference/ec2/register-instance-event-notification-attributes.html) command and set the `IncludeAllTagsOfInstance` parameter to `true`.

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

**To include specific tags in event notifications**  
Use the [register-instance-event-notification-attributes](https://docs.aws.amazon.com/cli/latest/reference/ec2/register-instance-event-notification-attributes.html) command and specify the tags to include by using the `InstanceTagKeys` parameter.

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

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

**To include all tags in event notifications**  
Use the [Register-EC2InstanceEventNotificationAttribute](https://docs.aws.amazon.com/powershell/latest/reference/items/Register-EC2InstanceEventNotificationAttribute.html) cmdlet.

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

**To include specific tags in event notifications**  
Use the [Register-EC2InstanceEventNotificationAttribute](https://docs.aws.amazon.com/powershell/latest/reference/items/Register-EC2InstanceEventNotificationAttribute.html) cmdlet.

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

------

## Remove tags from event notifications


You can remove tags from event notifications.

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

**To remove tags from event notifications**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Events**.

1. Choose **Actions**, **Manage event notifications**.

1. To remove all tags from event notifications, turn off **Include tags in event notifications**.

1. To remove specific tags from event notifications, choose the **X**) for the corresponding tag keys.

1. Choose **Save**.

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

**To remove all tags from event notifications**  
Use the [deregister-instance-event-notification-attributes](https://docs.aws.amazon.com/cli/latest/reference/ec2/deregister-instance-event-notification-attributes.html) command and set the `IncludeAllTagsOfInstance` parameter to `false`.

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

**To remove a tag from event notifications**  
Use the [deregister-instance-event-notification-attributes](https://docs.aws.amazon.com/cli/latest/reference/ec2/deregister-instance-event-notification-attributes.html) command and specify the tags to remove by using the `InstanceTagKeys` parameter.

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

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

**To remove all tags from event notifications**  
Use the [Unregister-EC2InstanceEventNotificationAttribute](https://docs.aws.amazon.com/powershell/latest/reference/items/Unregister-EC2InstanceEventNotificationAttribute.html) cmdlet.

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

**To remove a tag from event notifications**  
Use the [Unregister-EC2InstanceEventNotificationAttribute](https://docs.aws.amazon.com/powershell/latest/reference/items/Unregister-EC2InstanceEventNotificationAttribute.html) cmdlet.

```
Unregister-EC2InstanceEventNotificationAttribute `
    -InstanceTagAttribute_InstanceTagKey tag_key_3
```

------

## View the tags to be included in event notifications


You can view the tags that are to be included in event notifications.

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

**To view the tags that are to be included in event notifications**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Events**.

1. Choose **Actions**, **Manage event notifications**.

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

**To view the tags to be included in event notifications**  
Use the [describe-instance-event-notification-attributes](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instance-event-notification-attributes.html) command.

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

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

**To view the tags to be included in event notifications**  
Use the [Get-EC2InstanceEventNotificationAttribute](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2InstanceEventNotificationAttribute.html) cmdlet.

```
Get-EC2InstanceEventNotificationAttribute
```

------

# Reschedule a scheduled event for an EC2 instance
Reschedule scheduled events

You can reschedule an event so that it occurs at a specific date and time that suits you. After you reschedule an event, it might take a minute or two before the the updated date is displayed.

**Limitations**
+ Only events with an event deadline date can be rescheduled. The event can be rescheduled up to the event deadline date. The event deadline date is indicated in the **Deadline** column (console) and the `NotBeforeDeadline` field (AWS CLI).
+ Only events that have not yet started can be rescheduled. The start time is indicated in the **Start time** column (console) and the `NotBefore` field (AWS CLI). Events that are scheduled to start in the next 5 minutes can't be rescheduled.
+ The new event start time must be at least 60 minutes from the current time.
+ If you reschedule multiple events using the console, the event deadline date is determined by the event with the earliest event deadline date. 

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

**To reschedule an event**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Events**.

1. Choose **Resource type: instance** from the filter list.

1. Select one or more instances, and then choose **Actions**, **Schedule event**.

   Only events that have an event deadline date, indicated by a value for **Deadline**, can be rescheduled. If one of the selected events does not have a deadline date, **Actions**, **Schedule event** is disabled.

1. For **New start time**, enter a new date and time for the event. The new date and time must occur before the **Event deadline**.

1. Choose **Save**.

   It might take a minute or two for the updated event start time to be reflected in the console.

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

**To reschedule an event**  
Use the [https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-instance-event-start-time.html](https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-instance-event-start-time.html) command.

```
aws ec2 modify-instance-event-start-time \
    --instance-id i-1234567890abcdef0 \
    --instance-event-id instance-event-0d59937288b749b32 \
    --not-before 2020-03-25T10:00:00.000
```

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

**To reschedule an event**  
Use the [Edit-EC2InstanceEventStartTime](https://docs.aws.amazon.com/powershell/latest/reference/items/Edit-EC2InstanceEventStartTime.html) cmdlet.

```
Edit-EC2InstanceEventStartTime `
    -InstanceId i-1234567890abcdef0 `
    -InstanceEventId instance-event-0d59937288b749b32 `
    -NotBefore 2020-03-25T10:00:00.000
```

------

# Create custom event windows for scheduled events that affect your Amazon EC2 instances
Create custom event windows

You can define custom event windows that recur weekly for scheduled events that reboot, stop, or terminate your Amazon EC2 instances. You can associate one or more instances with an event window. If a scheduled event for those instances is planned, AWS will schedule the events within the associated event window.

You can use event windows to maximize workload availability by specifying event windows that occur during off-peak periods for your workload. You can also align the event windows with your internal maintenance schedules.

You define an event window by specifying a set of time ranges. The minimum time range is 2 hours. The combined time ranges must total at least 4 hours.

You can associate one or more instances with an event window by using either instance IDs or instance tags. You can also associate Dedicated Hosts with an event window by using the host ID.

**Warning**  
Event windows are applicable only for scheduled events that stop, reboot, or terminate instances.  
Event windows are not applicable for:  
Expedited scheduled events and network maintenance events. 
Unscheduled maintenance such as [automatic instance recovery](ec2-instance-recover.md) and unplanned reboots.

**Topics**
+ [

## Considerations
](#event-windows-considerations)
+ [

## Create an event window
](#create-event-windows)
+ [

## Associate a target with an event window
](#associate-target-event-window)
+ [

## Disassociate a target from an event window
](#disassociate-target-event-window)
+ [

## Modify an event window
](#modify-event-windows)
+ [

## Delete an event window
](#delete-event-windows)

## Considerations

+ All event window times are in UTC.
+ An event window can contain multiple time ranges. While each individual range must be at least 2 hours, the total duration across all ranges must be at least 4 hours.
+ Only one target type (instance ID, Dedicated Host ID, or instance tag) can be associated with an event window.
+ A target (instance ID, Dedicated Host ID, or instance tag) can only be associated with one event window.
+ A maximum of 100 instance IDs, or 50 Dedicated Host IDs, or 50 instance tags can be associated with an event window. The instance tags can be associated with any number of instances.
+ A maximum of 200 event windows can be created per AWS Region.
+ Multiple instances that are associated with event windows can potentially have scheduled events occur at the same time.
+ If AWS has already scheduled an event, modifying an event window won't change the time of the scheduled event. If the event has a deadline date, you can [reschedule the event](reschedule-event.md).
+ You can stop and start an instance before the scheduled event. This migrates the instance to a new host and clears the event.

## Create an event window


You can create one or more event windows. For each event window, you specify one or more blocks of time. For example, you can create an event window with blocks of time that occur every day at 4 AM for 2 hours. Or you can create an event window with blocks of time that occur on Sundays from 2 AM to 4 AM and on Wednesdays from 3 AM to 5 AM.

Event windows recur weekly until you delete them.

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

**To create an event window**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Events**.

1. Choose **Actions**, **Manage event windows**.

1. Choose **Create instance event window**.

1. For **Event window name**, enter a descriptive name for the event window.

1. For **Event window schedule**, choose to specify the blocks of time in the event window by using the cron schedule builder or by specifying time ranges.
   + If you choose **Cron schedule builder**, specify the following:

     1. For **Days (UTC)**, specify the days of the week on which the event window occurs.

     1. For **Start time (UTC)**, specify the time when the event window begins.

     1. For **Duration**, specify the duration of the blocks of time in the event window. The minimum duration per block of time is 2 hours. The minimum duration of the event window must equal or exceed 4 hours in total. All times are in UTC.
   + If you choose **Time ranges**, choose **Add new time range** and specify the start day and time and the end day and time. Repeat for each time range. The minimum duration per time range is 2 hours. The minimum duration for all time ranges combined must equal or exceed 4 hours in total.

1. (Optional) For **Target details**, associate one or more instances with the event window. Use instance IDs or instance tags to associate instances. Use host IDs to associate Dedicated Hosts. When these targets are scheduled for maintenance, the event will occur during this event window. 

   Note that you can create the event window without associating a target with the window. Later, you can modify the window to associate one or more targets.

1. (Optional) For **Event window tags**, choose **Add tag**, and enter the key and value for the tag. Repeat for each tag.

1. Choose **Create event window**.

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

**To create an event window with a time range**  
Use the [create-instance-event-window](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-instance-event-window.html) command.

```
aws ec2 create-instance-event-window \
    --time-range StartWeekDay=monday,StartHour=2,EndWeekDay=wednesday,EndHour=8 \
    --tag-specifications "ResourceType=instance-event-window,Tags=[{Key=K1,Value=V1}]" \
    --name myEventWindowName
```

The following is example output.

```
{
    "InstanceEventWindow": {
        "InstanceEventWindowId": "iew-0abcdef1234567890",
        "TimeRanges": [
            {
                "StartWeekDay": "monday",
                "StartHour": 2,
                "EndWeekDay": "wednesday",
                "EndHour": 8
            }
        ],
        "Name": "myEventWindowName",
        "State": "creating",
        "Tags": [
            {
                "Key": "K1",
                "Value": "V1"
            }
        ]
    }
}
```

**To create an event window with a cron expression**  
Use the [create-instance-event-window](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-instance-event-window.html) command.

```
aws ec2 create-instance-event-window \
    --cron-expression "* 21-23 * * 2,3" \
    --tag-specifications "ResourceType=instance-event-window,Tags=[{Key=K1,Value=V1}]" \
    --name myEventWindowName
```

The following is example output.

```
{
    "InstanceEventWindow": {
        "InstanceEventWindowId": "iew-0abcdef1234567890",
        "Name": "myEventWindowName",
        "CronExpression": "* 21-23 * * 2,3",
        "State": "creating",
        "Tags": [
            {
                "Key": "K1",
                "Value": "V1"
            }
        ]
    }
}
```

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

**To create an event window with a time range**  
Use the [New-EC2InstanceEventWindow](https://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2InstanceEventWindow.html) cmdlet.

```
$timeRange = New-Object Amazon.EC2.Model.InstanceEventWindowTimeRangeRequest
$timeRange.StartWeekDay = "monday"
$timeRange.EndWeekDay = "wednesday"
$timeRange.StartHour = 2
$timeRange.EndHour = 8
$tag = @{Key="key1"; Value="value1"}
$tagspec = New-Object Amazon.EC2.Model.TagSpecification
$tagspec.ResourceType = "instance-event-window"
$tagspec.Tags.Add($tag)
New-EC2InstanceEventWindow `
    -Name my-event-window `
    -TagSpecification $tagspec `
    -TimeRange @($timeRange)
```

The following is example output.

```
AssociationTarget     : 
CronExpression        : 
InstanceEventWindowId : iew-0abcdef1234567890
Name                  : my-event-window
State                 : creating
Tags                  : {key1}
TimeRanges            : {Amazon.EC2.Model.InstanceEventWindowTimeRange}
```

**To create an event window with a cron expression**  
Use the [New-EC2InstanceEventWindow](https://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2InstanceEventWindow.html) cmdlet.

```
$tag = @{Key="key1"; Value="value1"}
$tagspec = New-Object Amazon.EC2.Model.TagSpecification
$tagspec.ResourceType = "instance-event-window"
$tagspec.Tags.Add($tag)
New-EC2InstanceEventWindow `
    -Name my-event-window `
    -TagSpecification $tagspec`
    -CronExpression "* 21-23 * * 2,3"
```

The following is example output.

```
AssociationTarget     : 
CronExpression        : * 21-23 * * 2,3
InstanceEventWindowId : iew-0abcdef1234567890
Name                  : my-event-window
State                 : creating
Tags                  : {key1}
TimeRanges            : {}
```

------

## Associate a target with an event window


After you create an event window, you can associate targets with the event window. You can associate only one type of target with an event window. You can specify instance IDs, Dedicated Host IDs, or instance tags.

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

**To associate targets with an event window**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Events**.

1. Select the event window to modify.

1. Choose **Actions**, **Modify instance event window**.

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

**To associate instance tags with an event window**  
Use the [associate-instance-event-window](https://docs.aws.amazon.com/cli/latest/reference/ec2/associate-instance-event-window.html) command.

```
aws ec2 associate-instance-event-window \
    --instance-event-window-id iew-0abcdef1234567890 \
    --association-target "InstanceTags=[{Key=k2,Value=v2},{Key=k1,Value=v1}]"
```

The following is example output.

```
{
    "InstanceEventWindow": {
        "InstanceEventWindowId": "iew-0abcdef1234567890",
        "Name": "myEventWindowName",
        "CronExpression": "* 21-23 * * 2,3",
        "AssociationTarget": {
            "InstanceIds": [],
            "Tags": [
                {
                    "Key": "k2",
                    "Value": "v2"
                },
                {
                    "Key": "k1",
                    "Value": "v1"
                }
            ],
            "DedicatedHostIds": []
        },
        "State": "creating"
    }
}
```

**To associate instance IDs with an event window**  
Use the [associate-instance-event-window](https://docs.aws.amazon.com/cli/latest/reference/ec2/associate-instance-event-window.html) command.

```
aws ec2 associate-instance-event-window \
    --instance-event-window-id iew-0abcdef1234567890 \
    --association-target "InstanceIds=i-1234567890abcdef0,i-0598c7d356eba48d7"
```

The following is example output.

```
{
    "InstanceEventWindow": {
        "InstanceEventWindowId": "iew-0abcdef1234567890",
        "Name": "myEventWindowName",
        "CronExpression": "* 21-23 * * 2,3",
        "AssociationTarget": {
            "InstanceIds": [
                "i-1234567890abcdef0",
                "i-0598c7d356eba48d7"
            ],
            "Tags": [],
            "DedicatedHostIds": []
        },
        "State": "creating"
    }
}
```

**To associate a Dedicated Host with an event window**  
Use the [associate-instance-event-window](https://docs.aws.amazon.com/cli/latest/reference/ec2/associate-instance-event-window.html) command.

```
aws ec2 associate-instance-event-window \
    --instance-event-window-id iew-0abcdef1234567890 \
    --association-target "DedicatedHostIds=h-029fa35a02b99801d"
```

The following is example output.

```
{
    "InstanceEventWindow": {
        "InstanceEventWindowId": "iew-0abcdef1234567890",
        "Name": "myEventWindowName",
        "CronExpression": "* 21-23 * * 2,3",
        "AssociationTarget": {
            "InstanceIds": [],
            "Tags": [],
            "DedicatedHostIds": [
                "h-029fa35a02b99801d"
            ]
        },
        "State": "creating"
    }
}
```

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

**To associate instance tags with an event window**  
Use the [Register-EC2InstanceEventWindow](https://docs.aws.amazon.com/powershell/latest/reference/items/Register-EC2InstanceEventWindow.html) cmdlet.

```
$tag1 = @{Key="key1"; Value="value1"}
$tag2 = @{Key="key2"; Value="value2"}
Register-EC2InstanceEventWindow `
    -InstanceEventWindowId iew-0abcdef1234567890 `
    -AssociationTarget_InstanceTag @($tag1,$tag2)
```

**To associate instance IDs with an event window**  
Use the [Register-EC2InstanceEventWindow](https://docs.aws.amazon.com/powershell/latest/reference/items/Register-EC2InstanceEventWindow.html) cmdlet.

```
Register-EC2InstanceEventWindow `
    -InstanceEventWindowId iew-0abcdef1234567890 `
    -AssociationTarget_InstanceId i-1234567890abcdef0, i-0598c7d356eba48d7
```

**To associate a Dedicated Host with an event window**  
Use the [Register-EC2InstanceEventWindow](https://docs.aws.amazon.com/powershell/latest/reference/items/Register-EC2InstanceEventWindow.html) cmdlet.

```
Register-EC2InstanceEventWindow `
    -InstanceEventWindowId iew-0abcdef1234567890 `
    -AssociationTarget_DedicatedHostId h-029fa35a02b99801d
```

------

## Disassociate a target from an event window


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

**To disassociate targets with an event window**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Events**.

1. Select the event window to modify.

1. Choose **Actions**, **Modify instance event window**.

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

**To disassociate instance tags from an event window**  
Use the [disassociate-instance-event-window](https://docs.aws.amazon.com/cli/latest/reference//ec2/disassociate-instance-event-window.html) command.

```
aws ec2 disassociate-instance-event-window \
    --instance-event-window-id iew-0abcdef1234567890 \
    --association-target "InstanceTags=[{Key=k2,Value=v2},{Key=k1,Value=v1}]"
```

The following is example output.

```
{
    "InstanceEventWindow": {
        "InstanceEventWindowId": "iew-0abcdef1234567890",
        "Name": "myEventWindowName",
        "CronExpression": "* 21-23 * * 2,3",
        "AssociationTarget": {
            "InstanceIds": [],
            "Tags": [],
            "DedicatedHostIds": []
        },
        "State": "creating"
    }
}
```

**To disassociate instance IDs from an event window**  
Use the [disassociate-instance-event-window](https://docs.aws.amazon.com/cli/latest/reference/ec2/disassociate-instance-event-window.html) command.

```
aws ec2 disassociate-instance-event-window \
    --instance-event-window-id iew-0abcdef1234567890 \
    --association-target "InstanceIds=i-1234567890abcdef0,i-0598c7d356eba48d7"
```

The following is example output.

```
{
    "InstanceEventWindow": {
        "InstanceEventWindowId": "iew-0abcdef1234567890",
        "Name": "myEventWindowName",
        "CronExpression": "* 21-23 * * 2,3",
        "AssociationTarget": {
            "InstanceIds": [],
            "Tags": [],
            "DedicatedHostIds": []
        },
        "State": "creating"
    }
}
```

**To disassociate a Dedicated Host from an event window**  
Use the [disassociate-instance-event-window](https://docs.aws.amazon.com/cli/latest/reference/ec2/disassociate-instance-event-window.html) command.

```
aws ec2 disassociate-instance-event-window \
    --instance-event-window-id iew-0abcdef1234567890 \
    --association-target DedicatedHostIds=h-029fa35a02b99801d
```

The following is example output.

```
{
    "InstanceEventWindow": {
        "InstanceEventWindowId": "iew-0abcdef1234567890",
        "Name": "myEventWindowName",
        "CronExpression": "* 21-23 * * 2,3",
        "AssociationTarget": {
            "InstanceIds": [],
            "Tags": [],
            "DedicatedHostIds": []
        },
        "State": "creating"
    }
}
```

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

**To disassociate instance tags from an event window**  
Use the [Unregister-EC2InstanceEventWindow](https://docs.aws.amazon.com/powershell/latest/reference/items/Unregister-EC2InstanceEventWindow.html) cmdlet.

```
$tag1 = @{Key="key1"; Value="value1"}
$tag2 = @{Key="key2"; Value="value2"}
Unregister-EC2InstanceEventWindow `
    -InstanceEventWindowId iew-0abcdef1234567890 `
    -AssociationTarget_InstanceTag @($tag1, $tag2)
```

**To disassociate instance IDs from an event window**  
Use the [Unregister-EC2InstanceEventWindow](https://docs.aws.amazon.com/powershell/latest/reference/items/Unregister-EC2InstanceEventWindow.html) cmdlet.

```
Unregister-EC2InstanceEventWindow `
    -InstanceEventWindowId iew-0abcdef1234567890 `
    -AssociationTarget_InstanceId i-1234567890abcdef0, i-0598c7d356eba48d7
```

**To disassociate a Dedicated Host from an event window**  
Use the [Unregister-EC2InstanceEventWindow](https://docs.aws.amazon.com/powershell/latest/reference/items/Unregister-EC2InstanceEventWindow.html) cmdlet.

```
Unregister-EC2InstanceEventWindow `
    -InstanceEventWindowId iew-0abcdef1234567890 `
    -AssociationTarget_DedicatedHostId h-029fa35a02b99801d
```

------

## Modify an event window


You can modify all of the fields of an event window except its ID. For example, when daylight savings begin, you might want to modify the event window schedule. For existing event windows, you might want to add or remove targets.

You can modify either a time range or a cron expression when modifying the event window, but not both.

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

**To modify an event window**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Events**.

1. Choose **Actions**, **Manage event windows**.

1. Select the event window to modify, and then choose **Actions**, **Modify instance event window**.

1. Modify the fields in the event window, and then choose **Modify event window**.

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

**To modify the time range of an event window**  
Use the [modify-instance-event-window](https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-instance-event-window.html) command.

```
aws ec2 modify-instance-event-window 
    --instance-event-window-id iew-0abcdef1234567890 \
    --time-range StartWeekDay=monday,StartHour=2,EndWeekDay=wednesday,EndHour=8
```

The following is example output.

```
{
    "InstanceEventWindow": {
        "InstanceEventWindowId": "iew-0abcdef1234567890",
        "TimeRanges": [
            {
                "StartWeekDay": "monday",
                "StartHour": 2,
                "EndWeekDay": "wednesday",
                "EndHour": 8
            }
        ],
        "Name": "myEventWindowName",
        "AssociationTarget": {
            "InstanceIds": [
                "i-0abcdef1234567890",
                "i-0be35f9acb8ba01f0"
            ],
            "Tags": [],
            "DedicatedHostIds": []
        },
        "State": "creating",
        "Tags": [
            {
                "Key": "K1",
                "Value": "V1"
            }
        ]
    }
}
```

**To modify a set of time ranges for an event window**  
Use the [modify-instance-event-window](https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-instance-event-window.html) command.

```
aws ec2 modify-instance-event-window 
    --instance-event-window-id iew-0abcdef1234567890 \
    --time-range '[{"StartWeekDay": "monday", "StartHour": 2, "EndWeekDay": "wednesday", "EndHour": 8},
	  {"StartWeekDay": "thursday", "StartHour": 2, "EndWeekDay": "friday", "EndHour": 8}]'
```

The following is example output.

```
{
    "InstanceEventWindow": {
        "InstanceEventWindowId": "iew-0abcdef1234567890",
        "TimeRanges": [
            {
                "StartWeekDay": "monday",
                "StartHour": 2,
                "EndWeekDay": "wednesday",
                "EndHour": 8
            },
            {
                "StartWeekDay": "thursday",
                "StartHour": 2,
                "EndWeekDay": "friday",
                "EndHour": 8
            }
        ],
        "Name": "myEventWindowName",
        "AssociationTarget": {
            "InstanceIds": [
                "i-0abcdef1234567890",
                "i-0be35f9acb8ba01f0"
            ],
            "Tags": [],
            "DedicatedHostIds": []
        },
        "State": "creating",
        "Tags": [
            {
                "Key": "K1",
                "Value": "V1"
            }
        ]
    }
}
```

**To modify the cron expression of an event window**  
Use the [modify-instance-event-window](https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-instance-event-window.html) command.

```
aws ec2 modify-instance-event-window 
    --instance-event-window-id iew-0abcdef1234567890 \
    --cron-expression "* 21-23 * * 2,3"
```

The following is example output.

```
{
    "InstanceEventWindow": {
        "InstanceEventWindowId": "iew-0abcdef1234567890",
        "Name": "myEventWindowName",
        "CronExpression": "* 21-23 * * 2,3",
        "AssociationTarget": {
            "InstanceIds": [
                "i-0abcdef1234567890",
                "i-0be35f9acb8ba01f0"
            ],
            "Tags": [],
            "DedicatedHostIds": []
        },
        "State": "creating",
        "Tags": [
            {
                "Key": "K1",
                "Value": "V1"
            }
        ]
    }
}
```

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

**To modify the time range of an event window**  
Use the [Edit-EC2InstanceEventWindow](https://docs.aws.amazon.com/powershell/latest/reference/items/Edit-EC2InstanceEventWindow.html) cmdlet.

```
$timeRange1 = New-Object Amazon.EC2.Model.InstanceEventWindowTimeRangeRequest
$timeRange1.StartWeekDay = "monday"
$timeRange1.EndWeekDay = "wednesday"
$timeRange1.StartHour = 2
$timeRange1.EndHour = 8
$timeRange2 = New-Object Amazon.EC2.Model.InstanceEventWindowTimeRangeRequest
$timeRange2.StartWeekDay = "thursday"
$timeRange2.EndWeekDay = "friday"
$timeRange2.StartHour = 1
$timeRange2.EndHour = 6
Edit-EC2InstanceEventWindow `
    -InstanceEventWindowId iew-0abcdef1234567890 `
    -TimeRange @($timeRange1, $timeRange2)
```

**To modify the cron expression of an event window**  
Use the [Edit-EC2InstanceEventWindow](https://docs.aws.amazon.com/powershell/latest/reference/items/Edit-EC2InstanceEventWindow.html) cmdlet.

```
Edit-EC2InstanceEventWindow `
    -InstanceEventWindowId iew-0abcdef1234567890 `
    -CronExpression "* 21-23 * * 2,3"
```

------

## Delete an event window


You can delete one event window at a time.

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

**To delete an event window**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Events**.

1. Choose **Actions**, **Manage event windows**.

1. Select the event window to delete, and then choose **Actions**, **Delete instance event window**.

1. When prompted, enter **delete**, and then choose **Delete**.

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

**To delete an event window**  
Use the [delete-instance-event-window](https://docs.aws.amazon.com/cli/latest/reference/ec2/delete-instance-event-window.html) command and specify the event window to delete.

```
aws ec2 delete-instance-event-window \
    --instance-event-window-id iew-0abcdef1234567890
```

**To force-delete an event window**  
Use the `--force-delete` parameter if the event window is currently associated with targets.

```
aws ec2 delete-instance-event-window \
    --instance-event-window-id iew-0abcdef1234567890 \
    --force-delete
```

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

**To delete an event window**  
Use the [Remove-EC2InstanceEventWindow](https://docs.aws.amazon.com/powershell/latest/reference/items/Remove-EC2InstanceEventWindow.html) cmdlet.

```
Remove-EC2InstanceEventWindow `
    -InstanceEventWindowId iew-0abcdef1234567890
```

**To force-delete an event window**  
Use the [Remove-EC2InstanceEventWindow](https://docs.aws.amazon.com/powershell/latest/reference/items/Remove-EC2InstanceEventWindow.html) cmdlet.

```
Remove-EC2InstanceEventWindow `
    -InstanceEventWindowId iew-0abcdef1234567890 `
    -ForceDelete $true
```

------