1

I use python SDK with launch template to create multiple instances at once(about 20). Many instances of those instances are stuck in "To Be Started" status forever.

I can't even manually start them from portal as that is not a valid state and response is like "Operation failed. The resource status is invalid."

My code looks like this:

from aliyunsdkecs.request.v20140526 import RunInstancesRequest
from aliyunsdkcore.client import AcsClient
client = AcsClient(access_key_id, access_key_secret, region)
request = RunInstancesRequest.RunInstancesRequest()

request.set_InstanceName(name)
request.set_Tags([{'Key': 'env', 'Value': environment}, {'Key': 'project', 'Value': project_name}])
request.set_LaunchTemplateName(launch_template_name)
request.set_UserData(base64.b64encode(str.encode(user_data)))
request.set_Amount(amount)

response = json.loads(client.do_action_with_exception(request))

But I don't have the response returned at that time by such faulty instances.

Suraj Shrestha
  • 728
  • 11
  • 19

1 Answers1

-1

At present Instance can be any one of the five states:
https://www.alibabacloud.com/help/doc-detail/25687.htm


You can obtain the instance list:
https://www.alibabacloud.com/help/doc-detail/25505.htm


And then based on the status, you can delete multiple instances:
https://www.alibabacloud.com/help/doc-detail/126723.htm

Kishan
  • 1,630
  • 13
  • 19