Thanks for sharing . I need your help to fix this code import boto3 ec = boto3.client('ec2', 'ap-south-1') ec2 = boto3.resource('ec2', 'ap-south-1') def lambda_handler(event, context): instance_ids = [] reservations = ec.describe_instances().get('Reservations', []) for reservation in reservations: for instance in reservation['Instances']: Tags = {} for Tag in instance['Tags']: Tags[Tag['Key']] = Tag['Value'] if not 'Patch Group' in Tags: print(instance['InstanceId'] + " does not have patch group tag") elif Tags['Patch Group'] in ['Prod', 'Dev', 'QA']: print(instance['InstanceId'] + " has not correct Patch Group Tag")