translate aws cli code to python for lambda usage : I'm using a aws cli command to extract result for reporting and i must create a lambda that do the same job, but am facing many problem with synthax errors

the aws cli : $ aws ec2 describe-instances --query 'Reservations[].Instances[].[Tags[?Key==`platform`]|[0].Value, Tags[?Key==`resource-version`]|[0].Value]| sort_by(@, &[0])' --output table --filter Name=tag:platform,Values=aip,mmt,pame --profile prod | uniq

Could you help me to make the same code with python please ?