I want to use sqs with aws lambda, I create a new project for lambda(project A), and sqs code was written in another project(project B), what I want to do is, when some variables in B is calling sqs, it will trigger my lambda function in A, and do something, is that the correct way? Or sqs and lambda must in the same project?
AWS is not aware of your code projects.
You can add configure Amazon SQS to trigger an AWS Lambda function when a message is pushed to the SQS queue. AWS does not know/care about how that configuration was set, or where the code came from.
Think of it like delivering a letter. The post office will deliver the letter to the indicated address. It does not know/care who sent the letter.