boto error during ec2 instance deletion

22 views
Skip to first unread message

Abhi

unread,
Jan 6, 2015, 10:50:21 AM1/6/15
to boto-...@googlegroups.com
I am testing ec2 instance deletion with python boto (which was also created
with a python script). The disable_api_termination flag is set to True during
instance creation. Once the instance is created, another script uses the
following snippet to delete the instance:

connection.modify_instance_attribute(i.id, "disable_api_termination",
"False")
connection.terminate_instances(i.id)

but I get the "400 Bad request" error. I saw a similar post, but the thread was
a bit old and no definite solution was suggested (unless I missed something).
I would appreciate any pointers on the same.

Below is the traceback
Traceback (most recent call last):
File "/home/abhi/test//src/bin/aws_manage_instances", line 214, in <module>
main(sys.argv)
File "/home/abhi/test//src/bin/aws_manage_instances", line 186, in main
connection.modify_instance_attribute(i.id, "disable_api_termination",
"False")
File "/home/abhi/env/lib/python2.6/site-packages/boto/ec2/connection.py",
line 1275, in modify_instance_attribute
return self.get_status('ModifyInstanceAttribute', params, verb='POST')
File "/home/abhi/env/lib/python2.6/site-packages/boto/connection.py", line
1223, in get_status
raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>UnknownParameter</Code>
<Message>The parameter Disable_api_termination is not
recognized</Message></Error></Errors><RequestID>4ccaf91d-255f-4667-
8f6f-f51648cd6a07</RequestID></Response>


Adrian Klaver

unread,
Jan 6, 2015, 11:05:28 AM1/6/15
to boto-...@googlegroups.com
On 01/06/2015 07:36 AM, Abhi wrote:
> I am testing ec2 instance deletion with python boto (which was also created
> with a python script). The disable_api_termination flag is set to True during
> instance creation. Once the instance is created, another script uses the
> following snippet to delete the instance:
>
> connection.modify_instance_attribute(i.id, "disable_api_termination",
> "False")
> connection.terminate_instances(i.id)
>
> but I get the "400 Bad request" error. I saw a similar post, but the thread was
> a bit old and no definite solution was suggested (unless I missed something).
> I would appreciate any pointers on the same.

Not sure what version of boto you are using but according to this:

http://boto.readthedocs.org/en/2.3.0/ref/ec2.html

the attribute is:

disableApiTermination

>
> Below is the traceback
> Traceback (most recent call last):
> File "/home/abhi/test//src/bin/aws_manage_instances", line 214, in <module>
> main(sys.argv)
> File "/home/abhi/test//src/bin/aws_manage_instances", line 186, in main
> connection.modify_instance_attribute(i.id, "disable_api_termination",
> "False")
> File "/home/abhi/env/lib/python2.6/site-packages/boto/ec2/connection.py",
> line 1275, in modify_instance_attribute
> return self.get_status('ModifyInstanceAttribute', params, verb='POST')
> File "/home/abhi/env/lib/python2.6/site-packages/boto/connection.py", line
> 1223, in get_status
> raise self.ResponseError(response.status, response.reason, body)
> boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request
> <?xml version="1.0" encoding="UTF-8"?>
> <Response><Errors><Error><Code>UnknownParameter</Code>
> <Message>The parameter Disable_api_termination is not
> recognized</Message></Error></Errors><RequestID>4ccaf91d-255f-4667-
> 8f6f-f51648cd6a07</RequestID></Response>
>
>


--
Adrian Klaver
adrian...@aklaver.com

Abhi

unread,
Jan 6, 2015, 11:56:21 AM1/6/15
to boto-...@googlegroups.com
> Not sure what version of boto you are using but according to this:
>
> http://boto.readthedocs.org/en/2.3.0/ref/ec2.html
>
> the attribute is:
>
> disableApiTermination
>
Thank you, you are right, the attribute should be 'disableApiTermination';
possible cause of the confusion would be the parameter that we set initially -
to run a new instance we enable the flag with
connection.run_instances(....,disable_api_termination=True,....). Regardless,
should have verified with the docs first :)


Reply all
Reply to author
Forward
0 new messages