Hello I have a laravel
app with serverless
architecture. I'm getting an error:
cURL error 28: Failed to connect to fnhxdorrd22l.execute-api.ap-southeast-1.amazonaws.com port 443 after 7502 ms: Connection timed out (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://fnhxdorrdl22.execute-api.ap-southeast-1.amazonaws.com/oauth/token
Is there any configuration need for this or any inbound rules in order to call a function inside a function? BTW, it's working if it's a simple call or request without any call or trigger to other route or third parties.
Serverless.yml
service: laravel
provider:
name: aws
# The AWS region in which to deploy (us-east-1 is the default)
region: ap-southeast-1
# The stage of the application, e.g. dev, production, staging… ('dev' is the default)
stage: dev
profile: serverless
runtime: provided.al2
lambdaHashingVersion: 20201222321
package:
# Directories to exclude from deployment
patterns:
- '!node_modules/**'
- '!public/storage'
- '!resources/assets/**'
- '!storage/**'
- '!tests/**'
- 'storage/oauth-private.key'
- 'storage/oauth-public.key'
functions:
# This function runs the Laravel website/API
web:
handler: public/index.php
timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
vpc:
securityGroupIds:
- sg-042d6942052649ad59b0bc0
subnetIds:
- subnet-2c1464319824244
- subnet-474851e914424e4
- subnet-4424429f48129d7
layers:
- ${bref:layer.php-80-fpm}
events:
- httpApi: '*'
# This function lets us run artisan commands in Lambda
artisan:
handler: artisan
timeout: 120 # in seconds
layers:
- ${bref:layer.php-80} # PHP
- ${bref:layer.console} # The "console" layer
CodePudding user response:
A Lambda function configured to run in a VPC does not get a public IP address ever (regardless of the VPC public IP settings). The API Gateway URL is a public URL on the Internet. That API Gateway URL doesn't exist inside the VPC. In order for the Lambda function to make a connection to that URL the function has to be configured to run in a private VPC subnet that has a route to a NAT Gateway.