You have to set the internet connectivity with lambda since the createAPIKey function sends the internet request to the lambda function. If you are using VPC for your lambda, that means you can only connect within VPC. You will need a NAT service to connect to the internet. If you don't use VPC for your lambda, lambda is connecting to the internet by default. In your case, you seem to be setting the lambda with VPC, so you can't receive the request sent by the API gateway (request to create API keys).
Solution:
- If your lambda has VPC groups, create a NAT to connect with your lambda. Link
- Detach your lambda with original VPC groups and it will automatically connect to the internet. (This is a dangerous approach, but if you are in a testing environment, you can use this method to check if the timeout problem of the lambda that doesn't have internet access.)