EC2.Client.
run_scheduled_instances
(**kwargs)¶Launches the specified Scheduled Instances.
Before you can launch a Scheduled Instance, you must purchase it and obtain an identifier using PurchaseScheduledInstances.
You must launch a Scheduled Instance during its scheduled time period. You can't stop or reboot a Scheduled Instance, but you can terminate it as needed. If you terminate a Scheduled Instance before the current scheduled time period ends, you can launch it again after a few minutes. For more information, see Scheduled Instances in the Amazon EC2 User Guide .
See also: AWS API Documentation
Request Syntax
response = client.run_scheduled_instances(
ClientToken='string',
DryRun=True|False,
InstanceCount=123,
LaunchSpecification={
'BlockDeviceMappings': [
{
'DeviceName': 'string',
'Ebs': {
'DeleteOnTermination': True|False,
'Encrypted': True|False,
'Iops': 123,
'SnapshotId': 'string',
'VolumeSize': 123,
'VolumeType': 'string'
},
'NoDevice': 'string',
'VirtualName': 'string'
},
],
'EbsOptimized': True|False,
'IamInstanceProfile': {
'Arn': 'string',
'Name': 'string'
},
'ImageId': 'string',
'InstanceType': 'string',
'KernelId': 'string',
'KeyName': 'string',
'Monitoring': {
'Enabled': True|False
},
'NetworkInterfaces': [
{
'AssociatePublicIpAddress': True|False,
'DeleteOnTermination': True|False,
'Description': 'string',
'DeviceIndex': 123,
'Groups': [
'string',
],
'Ipv6AddressCount': 123,
'Ipv6Addresses': [
{
'Ipv6Address': 'string'
},
],
'NetworkInterfaceId': 'string',
'PrivateIpAddress': 'string',
'PrivateIpAddressConfigs': [
{
'Primary': True|False,
'PrivateIpAddress': 'string'
},
],
'SecondaryPrivateIpAddressCount': 123,
'SubnetId': 'string'
},
],
'Placement': {
'AvailabilityZone': 'string',
'GroupName': 'string'
},
'RamdiskId': 'string',
'SecurityGroupIds': [
'string',
],
'SubnetId': 'string',
'UserData': 'string'
},
ScheduledInstanceId='string'
)
Unique, case-sensitive identifier that ensures the idempotency of the request. For more information, see Ensuring Idempotency.
This field is autopopulated if not provided.
DryRunOperation
. Otherwise, it is UnauthorizedOperation
.The number of instances.
Default: 1
[REQUIRED]
The launch specification. You must match the instance type, Availability Zone, network, and platform of the schedule that you purchased.
The block device mapping entries.
Describes a block device mapping for a Scheduled Instance.
The device name (for example, /dev/sdh
or xvdh
).
Parameters used to set up EBS volumes automatically when the instance is launched.
Indicates whether the volume is deleted on instance termination.
Indicates whether the volume is encrypted. You can attached encrypted volumes only to instances that support them.
The number of I/O operations per second (IOPS) to provision for an io1
or io2
volume, with a maximum ratio of 50 IOPS/GiB for io1
, and 500 IOPS/GiB for io2
. Range is 100 to 64,000 IOPS for volumes in most Regions. Maximum IOPS of 64,000 is guaranteed only on instances built on the Nitro System. Other instance families guarantee performance up to 32,000 IOPS. For more information, see Amazon EBS volume types in the Amazon EC2 User Guide .
This parameter is valid only for Provisioned IOPS SSD ( io1
and io2
) volumes.
The ID of the snapshot.
The size of the volume, in GiB.
Default: If you're creating the volume from a snapshot and don't specify a volume size, the default is the snapshot size.
The volume type. gp2
for General Purpose SSD, io1
or io2
for Provisioned IOPS SSD, Throughput Optimized HDD for st1
, Cold HDD for sc1
, or standard
for Magnetic.
Default: gp2
To omit the device from the block device mapping, specify an empty string.
The virtual device name ( ephemeral
N). Instance store volumes are numbered starting from 0. An instance type with two available instance store volumes can specify mappings for ephemeral0
and ephemeral1
. The number of available instance store volumes depends on the instance type. After you connect to the instance, you must mount the volume.
Constraints: For M3 instances, you must specify instance store volumes in the block device mapping for the instance. When you launch an M3 instance, we ignore any instance store volumes specified in the block device mapping for the AMI.
Indicates whether the instances are optimized for EBS I/O. This optimization provides dedicated throughput to Amazon EBS and an optimized configuration stack to provide optimal EBS I/O performance. This optimization isn't available with all instance types. Additional usage charges apply when using an EBS-optimized instance.
Default: false
The IAM instance profile.
The Amazon Resource Name (ARN).
The name.
The ID of the Amazon Machine Image (AMI).
The instance type.
The ID of the kernel.
The name of the key pair.
Enable or disable monitoring for the instances.
Indicates whether monitoring is enabled.
The network interfaces.
Describes a network interface for a Scheduled Instance.
Indicates whether to assign a public IPv4 address to instances launched in a VPC. The public IPv4 address can only be assigned to a network interface for eth0, and can only be assigned to a new network interface, not an existing one. You cannot specify more than one network interface in the request. If launching into a default subnet, the default value is true
.
Indicates whether to delete the interface when the instance is terminated.
The description.
The index of the device for the network interface attachment.
The IDs of the security groups.
The number of IPv6 addresses to assign to the network interface. The IPv6 addresses are automatically selected from the subnet range.
The specific IPv6 addresses from the subnet range.
Describes an IPv6 address.
The IPv6 address.
The ID of the network interface.
The IPv4 address of the network interface within the subnet.
The private IPv4 addresses.
Describes a private IPv4 address for a Scheduled Instance.
Indicates whether this is a primary IPv4 address. Otherwise, this is a secondary IPv4 address.
The IPv4 address.
The number of secondary private IPv4 addresses.
The ID of the subnet.
The placement information.
The Availability Zone.
The name of the placement group.
The ID of the RAM disk.
The IDs of the security groups.
The ID of the subnet in which to launch the instances.
The base64-encoded MIME user data.
[REQUIRED]
The Scheduled Instance ID.
dict
Response Syntax
{
'InstanceIdSet': [
'string',
]
}
Response Structure
(dict) --
Contains the output of RunScheduledInstances.
InstanceIdSet (list) --
The IDs of the newly launched instances.
Examples
This example launches the specified Scheduled Instance in a VPC.
response = client.run_scheduled_instances(
InstanceCount=1,
LaunchSpecification={
'IamInstanceProfile': {
'Name': 'my-iam-role',
},
'ImageId': 'ami-12345678',
'InstanceType': 'c4.large',
'KeyName': 'my-key-pair',
'NetworkInterfaces': [
{
'AssociatePublicIpAddress': True,
'DeviceIndex': 0,
'Groups': [
'sg-12345678',
],
'SubnetId': 'subnet-12345678',
},
],
},
ScheduledInstanceId='sci-1234-1234-1234-1234-123456789012',
)
print(response)
Expected Output:
{
'InstanceIdSet': [
'i-1234567890abcdef0',
],
'ResponseMetadata': {
'...': '...',
},
}
This example launches the specified Scheduled Instance in EC2-Classic.
response = client.run_scheduled_instances(
InstanceCount=1,
LaunchSpecification={
'IamInstanceProfile': {
'Name': 'my-iam-role',
},
'ImageId': 'ami-12345678',
'InstanceType': 'c4.large',
'KeyName': 'my-key-pair',
'Placement': {
'AvailabilityZone': 'us-west-2b',
},
'SecurityGroupIds': [
'sg-12345678',
],
},
ScheduledInstanceId='sci-1234-1234-1234-1234-123456789012',
)
print(response)
Expected Output:
{
'InstanceIdSet': [
'i-1234567890abcdef0',
],
'ResponseMetadata': {
'...': '...',
},
}