Skip to main content

instance_event_windows

Creates, updates, deletes, gets or lists an instance_event_windows resource.

Overview

Nameinstance_event_windows
TypeResource
Idaws.ec2.instance_event_windows

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
association_targetstringOne or more targets associated with the event window.
cron_expressionstringThe cron expression defined for the event window.
instance_event_window_idstringThe ID of the event window.
namestringThe name of the event window.
statestringThe current state of the event window.
tagsstringThe instance tags associated with the event window.
time_rangesstringOne or more time ranges defined for the event window.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_instance_event_windowsselectregionDryRun, InstanceEventWindowId, Filter, MaxResults, NextTokenDescribes the specified event windows or all event windows. If you specify event window IDs, the output includes information for only the specified event windows. If you specify filters, the output includes information for only those event windows that meet the filter criteria. If you do not specify event windows IDs or filters, the output includes information for all event windows, which can affect performance. We recommend that you use pagination to ensure that the operation returns quickly and successfully. For more information, see Define event windows for scheduled events in the Amazon EC2 User Guide.
create_instance_event_windowinsertregionDryRun, Name, TimeRange, CronExpression, TagSpecificationCreates an event window in which scheduled events for the associated Amazon EC2 instances can run. You can define either a set of time ranges or a cron expression when creating the event window, but not both. All event window times are in UTC. You can create up to 200 event windows per Amazon Web Services Region. When you create the event window, targets (instance IDs, Dedicated Host IDs, or tags) are not yet associated with it. To ensure that the event window can be used, you must associate one or more targets with it by using the AssociateInstanceEventWindow API. 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 AutoRecovery and unplanned reboots. For more information, see Define event windows for scheduled events in the Amazon EC2 User Guide.
associate_instance_event_windowupdateInstanceEventWindowId, AssociationTarget, regionDryRunAssociates one or more targets with an event window. Only one type of target (instance IDs, Dedicated Host IDs, or tags) can be specified with an event window. For more information, see Define event windows for scheduled events in the Amazon EC2 User Guide.
modify_instance_event_windowupdateInstanceEventWindowId, regionDryRun, Name, TimeRange, CronExpressionModifies the specified event window. You can define either a set of time ranges or a cron expression when modifying the event window, but not both. To modify the targets associated with the event window, use the AssociateInstanceEventWindow and DisassociateInstanceEventWindow API. If Amazon Web Services has already scheduled an event, modifying an event window won't change the time of the scheduled event. For more information, see Define event windows for scheduled events in the Amazon EC2 User Guide.
delete_instance_event_windowdeleteInstanceEventWindowId, regionDryRun, ForceDeleteDeletes the specified event window. For more information, see Define event windows for scheduled events in the Amazon EC2 User Guide.
disassociate_instance_event_windowexecInstanceEventWindowId, AssociationTarget, regionDryRunDisassociates one or more targets from an event window. For more information, see Define event windows for scheduled events in the Amazon EC2 User Guide.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
AssociationTargetobjectOne or more targets to disassociate from the specified event window.
InstanceEventWindowIdstringThe ID of the event window.
regionstringAWS region (default: us-east-1)
CronExpressionstringThe cron expression of the event window, for example, * 0-4,20-23 * * 1,5. Constraints: Only hour and day of the week values are supported. For day of the week values, you can specify either integers 0 through 6, or alternative single values SUN through SAT. The minute, month, and year must be specified by *. The hour value must be one or a multiple range, for example, 0-4 or 0-4,20-23. Each hour range must be >= 2 hours, for example, 0-2 or 20-23. The event window must be >= 4 hours. The combined total time ranges in the event window must be >= 4 hours. For more information about cron expressions, see cron on the Wikipedia website.
DryRunbooleanChecks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.
FilterarrayOne or more filters. dedicated-host-id - The event windows associated with the specified Dedicated Host ID. event-window-name - The event windows associated with the specified names. instance-id - The event windows associated with the specified instance ID. instance-tag - The event windows associated with the specified tag and value. instance-tag-key - The event windows associated with the specified tag key, regardless of the value. instance-tag-value - The event windows associated with the specified tag value, regardless of the key. tag:<key> - The key/value combination of a tag assigned to the event window. Use the tag key in the filter name and the tag value as the filter value. For example, to find all resources that have a tag with the key Owner and the value CMX, specify tag:Owner for the filter name and CMX for the filter value. tag-key - The key of a tag assigned to the event window. Use this filter to find all event windows that have a tag with a specific key, regardless of the tag value. tag-value - The value of a tag assigned to the event window. Use this filter to find all event windows that have a tag with a specific value, regardless of the tag key.
ForceDeletebooleanSpecify true to force delete the event window. Use the force delete parameter if the event window is currently associated with targets.
InstanceEventWindowIdarrayThe IDs of the event windows.
MaxResultsintegerThe maximum number of results to return in a single call. To retrieve the remaining results, make another call with the returned NextToken value. This value can be between 20 and 500. You cannot specify this parameter and the event window IDs parameter in the same call.
NamestringThe name of the event window.
NextTokenstringThe token to request the next page of results.
TagSpecificationarrayThe tags to apply to the event window.
TimeRangearrayThe time ranges of the event window.

SELECT examples

Describes the specified event windows or all event windows. If you specify event window IDs, the output includes information for only the specified event windows. If you specify filters, the output includes information for only those event windows that meet the filter criteria. If you do not specify event windows IDs or filters, the output includes information for all event windows, which can affect performance. We recommend that you use pagination to ensure that the operation returns quickly and successfully. For more information, see Define event windows for scheduled events in the Amazon EC2 User Guide.

SELECT
association_target,
cron_expression,
instance_event_window_id,
name,
state,
tags,
time_ranges
FROM aws.ec2.instance_event_windows
WHERE region = '{{ region }}' -- required
AND DryRun = '{{ DryRun }}'
AND InstanceEventWindowId = '{{ InstanceEventWindowId }}'
AND Filter = '{{ Filter }}'
AND MaxResults = '{{ MaxResults }}'
AND NextToken = '{{ NextToken }}'
;

INSERT examples

Creates an event window in which scheduled events for the associated Amazon EC2 instances can run. You can define either a set of time ranges or a cron expression when creating the event window, but not both. All event window times are in UTC. You can create up to 200 event windows per Amazon Web Services Region. When you create the event window, targets (instance IDs, Dedicated Host IDs, or tags) are not yet associated with it. To ensure that the event window can be used, you must associate one or more targets with it by using the AssociateInstanceEventWindow API. 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 AutoRecovery and unplanned reboots. For more information, see Define event windows for scheduled events in the Amazon EC2 User Guide.

INSERT INTO aws.ec2.instance_event_windows (
region,
DryRun,
Name,
TimeRange,
CronExpression,
TagSpecification
)
SELECT
'{{ region }}',
'{{ DryRun }}',
'{{ Name }}',
'{{ TimeRange }}',
'{{ CronExpression }}',
'{{ TagSpecification }}'
RETURNING
association_target,
cron_expression,
instance_event_window_id,
name,
state,
tags,
time_ranges
;

UPDATE examples

Associates one or more targets with an event window. Only one type of target (instance IDs, Dedicated Host IDs, or tags) can be specified with an event window. For more information, see Define event windows for scheduled events in the Amazon EC2 User Guide.

UPDATE aws.ec2.instance_event_windows
SET
-- No updatable properties
WHERE
InstanceEventWindowId = '{{ InstanceEventWindowId }}' --required
AND AssociationTarget = '{{ AssociationTarget }}' --required
AND region = '{{ region }}' --required
AND DryRun = {{ DryRun}}
RETURNING
association_target,
cron_expression,
instance_event_window_id,
name,
state,
tags,
time_ranges;

DELETE examples

Deletes the specified event window. For more information, see Define event windows for scheduled events in the Amazon EC2 User Guide.

DELETE FROM aws.ec2.instance_event_windows
WHERE InstanceEventWindowId = '{{ InstanceEventWindowId }}' --required
AND region = '{{ region }}' --required
AND DryRun = '{{ DryRun }}'
AND ForceDelete = '{{ ForceDelete }}'
;

Lifecycle Methods

Disassociates one or more targets from an event window. For more information, see Define event windows for scheduled events in the Amazon EC2 User Guide.

EXEC aws.ec2.instance_event_windows.disassociate_instance_event_window
@InstanceEventWindowId='{{ InstanceEventWindowId }}' --required,
@AssociationTarget='{{ AssociationTarget }}' --required,
@region='{{ region }}' --required,
@DryRun={{ DryRun }}
;