According to the deadlinecommand arguments help, launching a Spot Fleet should be possible by providing a compatible JSON file with the keys
{“StackName”: “”, “Capacity”: 1, “InstanceTypes”: [], “SpotPrice”: 1, “AmiId”: “”, “AmiName”: “”, “KeyName”: “”, “AvailabilityZones”: [], “AWSPortalRequestType”: “”, “IdleTime”: 2, “Groups”: [], “Pools”: [], “InstanceTags”: {}, “Context”: “”, }
I have built a reasonably correct JSON file with all the required information including the Stack Name (automatically extracted from the prefix of the Placement Group of the Gateway instance), the instance types, the AMI ID, AMI Name and DashKey as used by my manually-launched Spot Fleet instances, the ‘AvailabilityZones’: [‘us-west-2a’, ‘us-west-2b’, ‘us-west-2c’] because my d Zone does not carry any GPU instances, and ‘AWSPortalRequestType’: ‘maintain’ which is an assumption, but hopefully correct.
I have also set the InstanceTags to the same values the AWS Portal would create.
The rest of the values like Pools, Groups and Context were left empty like in the template example.
When I run the command, I see in the Console the following:
2024-03-06 10:40:13: PYTHON: Please enter your AWS Access Key ID:
2024-03-06 10:40:13: PYTHON: Error reading spot fleet parameters, please ensure your input json file is in the format: {"StackName": "", "Capacity": 1, "InstanceTypes": [], "SpotPrice": 1, "AmiId": "", "AmiName": "", "KeyName": "", "AvailabilityZones": [], "AWSPortalRequestType": "", "IdleTime": 2, "Groups": [], "Pools": [], "InstanceTags": {}, "Context": "", }
2024-03-06 10:40:13: PYTHON: Object reference not set to an instance of an object.
The log implies that
- The AWS access key (and maybe the secret access key) need to be provided explicitly
- The JSON file is somehow incorrect.
- An error occurred internally when creating some object.
It is very possible that some of these are side effects of a single error. However, since the AWS Access Key ID message comes first, I suspect that it is the first issue to tackle.
So my question is - what is the correct way of providing credentials to this particular command? I have aws credentials configured on the machine and my boto3 scripts can perform pretty much any operation. I am willing to attempt to recreate the whole Spot Fleet logic myself (although it would require some reverse engineering to configure a Spot Fleet that completely meshes with AWS Portal), but given that the deadlinecommand offers such a command, it would be a waste of time.
That being said, I could imagine that the deadlinecommand -CreateSpotFleet
is for internal use only, and the documentation simply fails to tell us that (esp. given the fact that I added that documentation chapter myself based on the command’s help and forgot to ask anyone while I could…)
Thanks in advance!