I am trying to edit tag name in EC2 with a Lambda function in python 3.7
Unfortunately, I get the following error :
[ERROR] AttributeError: 'ec2.ServiceResource' object has no attribute 'delete_tags'
But I have checked the documentation on boto3 and "delete_tags" class exist : https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#id996
The "create_tags" class work well.
Here is the lambda function :
import boto3
ec2 = boto3.resource('ec2')
def lambda_handler(event, context):
filters = [{
'Name': 'tag:Scheduler',
'Values': ['True']
}]
instances = ec2.instances.filter(Filters=filters)
ids = [instance.id for instance in instances]
print(ids)
ec2.delete_tags(Resources=ids,Tags=[{'Key': 'Scheduler','Value': 'True'}])
ec2.create_tags(Resources=ids,Tags=[{'Key': 'Scheduler','Value': 'False'}])
boto3.resource
but the class that you found is coming fromboto3.client
. – Lamanus