Found a solution that works for me:
PIPELINE_EXECUTION_ID=$(aws codepipeline get-pipeline-state --region ${AWS_REGION} --name my-pipeline --query 'stageStates[?actionStates[?latestExecution.externalExecutionId==`'${CODEBUILD_BUILD_ID}'`]].latestExecution.pipelineExecutionId' --output text)
SOURCE_REPO_COMMIT_HASH=$(aws codepipeline get-pipeline-execution --pipeline-name my-pipeline --pipeline-execution-id $PIPELINE_EXECUTION_ID --query "pipelineExecution.artifactRevisions[?name=='src'].revisionId" --output text)
You might need to change "src" in artifactRevisions[?name=='src']
to whatever value is valid for you project.
From @IfTrue's comment below:
Sidenote for other readers: the portion sashoalm mentions that might need changed ('src') is the name of the Output Artifact in the "action group" inside of the "stage" in your CodePipeline where it watches for the CodeCommit change. Also this part of the AWS docs explains the magic behind the query: docs.aws.amazon.com/cli/latest/reference/codepipeline/… – IfTrue