-
Notifications
You must be signed in to change notification settings - Fork 0
/
request_spot_instance.py
executable file
·46 lines (44 loc) · 1.18 KB
/
request_spot_instance.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import boto3
client = boto3.client('ec2', region_name='us-east-1', aws_access_key_id='', aws_secret_access_key='')
response = client.request_spot_fleet (
DryRun = False,
SpotFleetRequestConfig= {
"IamFleetRole": "",
"AllocationStrategy": "lowestPrice",
"TargetCapacity": 5,
"SpotPrice": "0.025",
"ValidFrom": "2017-04-19T15:21:10Z",
"ValidUntil": "2018-04-19T15:21:10Z",
"TerminateInstancesWithExpiration": True,
"LaunchSpecifications": [
{
"ImageId": "ami-f4cc1de2",
"InstanceType": "r4.large",
"KeyName": "social-media",
"EbsOptimized": True,
"Monitoring": {
"Enabled": True
},
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda1",
"Ebs": {
"DeleteOnTermination": True,
"VolumeType": "gp2",
"VolumeSize": 8,
"SnapshotId": ""
}
}
],
"SecurityGroups": [
{
"GroupId": ""
}
],
"UserData": ""
}
],
"Type": "maintain",
"ReplaceUnhealthyInstances": True
}
)