Here is the code.
import boto3
lambda_client = boto3.client('lambda')
response = lambda_client.create_function(
FunctionName='your-function-name',
Runtime='python3.8',
Role='your-iam-role-arn',
Handler='your-handler-function',
Code={
'S3Bucket': 'your-bucket-name',
'S3Key': 'your-code.zip'
}
)
print(response)