You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm developing some lambdas with golang, and I'm trying to connect to a postres DB, however, the lambdas are not able to connect to my local development database.
The database is running in another container, but I created a docker network and I haven't had any luck connecting to the DB from the local running lambda.
Now, to start the API, I'm doing sam local start-api --docker-network 72a7d526bfc1ea9f0556b8349539d256c7519d05143920087dec0e05f2d73e450
Then in the lambdas when I invoke them, they say 2024/11/22 18:29:18 Failed to ping the database: dial tcp [::1]:5432: connect: connection refused
And if I do a docker network inspect 72a7d526bfc1ea9f0556b8349539d256c7519d05143920087dec0e05f2d73e450 I only see the DB container connected to that network.
Observed result:
2024-11-23 13:08:34,719 | Config file location: C:\Users\Sebassllr\Documents\SecurityApp\VigiTrack-Backend\samconfig.toml
2024-11-23 13:08:34,719 | Config file 'C:\Users\Sebassllr\Documents\SecurityApp\VigiTrack-Backend\samconfig.toml' does not exist
2024-11-23 13:08:34,729 | Using SAM Template at C:\Users\Sebassllr\Documents\SecurityApp\VigiTrack-Backend\.aws-sam\build\template.yaml
2024-11-23 13:08:34,755 | Using config file: samconfig.toml, config environment: default
2024-11-23 13:08:34,755 | Expand command line arguments to:
2024-11-23 13:08:34,755 | --template_file=C:\Users\Sebassllr\Documents\SecurityApp\VigiTrack-Backend\.aws-sam\build\template.yaml --docker_network=72a7d526bfc1ea9f0556b8349539d256c7519d05143920087dec0e05f2d73e45 --host=127.0.0.1 --port=3000 --static_dir=public --layer_cache_basedir=C:\Users\Sebassllr\AppData\Roaming\AWS SAM\layers-pkg --container_host=localhost --container_host_interface=127.0.0.1
2024-11-23 13:08:35,991 | local start-api command is called
2024-11-23 13:08:35,995 | No Parameters detected in the template
2024-11-23 13:08:36,199 | Sam customer defined id is more priority than other IDs. Customer defined id for resource VigiTrack is VigiTrack
2024-11-23 13:08:36,200 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2024-11-23 13:08:36,200 | 0 stacks found in the template
2024-11-23 13:08:36,200 | No Parameters detected in the template
2024-11-23 13:08:36,214 | Sam customer defined id is more priority than other IDs. Customer defined id for resource VigiTrack is VigiTrack
2024-11-23 13:08:36,214 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2024-11-23 13:08:36,216 | 2 resources found in the stack
2024-11-23 13:08:36,216 | Found Serverless function with name='VigiTrack' and CodeUri='VigiTrack'
2024-11-23 13:08:36,217 | --base-dir is not presented, adjusting uri VigiTrack relative to C:\Users\Sebassllr\Documents\SecurityApp\VigiTrack-Backend\.aws-sam\build\template.yaml
2024-11-23 13:08:36,266 | Found '7' API Events in Serverless function with name 'VigiTrack'
2024-11-23 13:08:36,266 | Detected Inline Swagger definition
2024-11-23 13:08:36,267 | Lambda function integration not found in Swagger document at path='/items' method='put'
2024-11-23 13:08:36,267 | Lambda function integration not found in Swagger document at path='/items' method='get'
2024-11-23 13:08:36,267 | Lambda function integration not found in Swagger document at path='/user' method='post'
2024-11-23 13:08:36,267 | Lambda function integration not found in Swagger document at path='/user' method='get'
2024-11-23 13:08:36,267 | Lambda function integration not found in Swagger document at path='/hello' method='put'
2024-11-23 13:08:36,267 | Lambda function integration not found in Swagger document at path='/hello' method='post'2024-11-23 13:08:36,267 | Lambda function integration not found in Swagger document at path='/hello' method='get'
2024-11-23 13:08:36,267 | Found '0' APIs in resource 'ServerlessRestApi'
2024-11-23 13:08:36,268 | Removed duplicates from '0' Explicit APIs and '7' Implicit APIs to produce '7' APIs
2024-11-23 13:08:36,268 | 3 APIs found in the template
2024-11-23 13:08:36,275 | Mounting VigiTrack at http://127.0.0.1:3000/hello [GET, POST, PUT]
2024-11-23 13:08:36,275 | Mounting VigiTrack at http://127.0.0.1:3000/items [GET, PUT]
2024-11-23 13:08:36,275 | Mounting VigiTrack at http://127.0.0.1:3000/user [GET, POST]
2024-11-23 13:08:36,275 | You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. If you used sam build before running local commands, you will need to re-run sam build for the changes to be picked up. You only need to restart SAM CLI if you update your AWS SAM template
2024-11-23 13:08:36,276 | Localhost server is starting up. Multi-threading = True
2024-11-23 13:08:36 WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:3000
When I call my endpoint I get 2024/11/22 18:29:18 Failed to ping the database: dial tcp [::1]:5432: connect: connection refused
Expected result:
I'd except this to be listed under my docker network inspect command.
However, it is not showing there. Also I'd expect to be able to connect from the lambda to my DB.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Hello!
Description:
I'm developing some lambdas with golang, and I'm trying to connect to a postres DB, however, the lambdas are not able to connect to my local development database.
The database is running in another container, but I created a docker network and I haven't had any luck connecting to the DB from the local running lambda.
Steps to reproduce:
Im creating the network and DB as the following:
Now, to start the API, I'm doing
sam local start-api --docker-network 72a7d526bfc1ea9f0556b8349539d256c7519d05143920087dec0e05f2d73e450
Then in the lambdas when I invoke them, they say
2024/11/22 18:29:18 Failed to ping the database: dial tcp [::1]:5432: connect: connection refused
And if I do a
docker network inspect 72a7d526bfc1ea9f0556b8349539d256c7519d05143920087dec0e05f2d73e450
I only see the DB container connected to that network.Observed result:
When I call my endpoint I get
2024/11/22 18:29:18 Failed to ping the database: dial tcp [::1]:5432: connect: connection refused
Expected result:
I'd except this to be listed under my
docker network inspect
command.However, it is not showing there. Also I'd expect to be able to connect from the lambda to my DB.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: SAM CLI, version 1.78.0The text was updated successfully, but these errors were encountered: