Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29450

How to change termination protection by boto3

$
0
0

I want to teminate many AWS ec2 instance,then i use boto3 like this:

#!/usr/bin/env python 
#coding=utf8

import boto3
ec2 = boto3.resource(
    'ec2',
    aws_access_key_id="<AK>",
    aws_secret_access_key="<SK>",
    region_name='eu-central-1'
)

instances = ec2.instances.filter(
    Filters=[{'Name': 'instance-state-name', 'Values': ['stopped']}])

ids = ['id1','id2'.....'idn']
status = ec2.instances.filter(InstanceIds=ids).terminate()
print(status)

But I got a ERROR:

botocore.exceptions.ClientError: An error occurred (OperationNotPermitted) when calling the TerminateInstances operation: The instance 'i-0f06b49c1f16dcfde' may not be terminated. Modify its 'disableApiTermination' instance attribute and try again.

please tell me how to modify the disableApiTermination.


Viewing all articles
Browse latest Browse all 29450

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>