CodexBloom - Programming Q&A Platform

AWS App Runner Service scenarios to Connect to RDS Instance with VPC Configuration

👀 Views: 12 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-16
aws apprunner rds vpc javascript

I'm optimizing some code but This might be a silly question, but I'm trying to deploy a web application using AWS App Runner that needs to connect to an RDS (PostgreSQL) instance located in a VPC... I've configured the App Runner service to use a VPC connector, but I'm getting the following behavior when the application tries to access the database: `OperationalError: could not connect to server: Connection timed out`. Here is the relevant configuration for the App Runner service: ```yaml Version: '1.0' Service: Name: my-app-runner-service Source: ImageRepository: ImageIdentifier: my-docker-repo/my-app:latest ImageConfiguration: Port: '8080' VpcConnector: VpcConnectorArn: arn:aws:apprunner:us-east-1:123456789012:vpc-connector/my-vpc-connector SecurityGroups: - sg-0123456789abcdef0 Subnets: - subnet-12345678 InstanceConfiguration: Cpu: '1 vCPU' Memory: '2 GB' ``` I have ensured that the security group associated with the RDS instance allows inbound traffic from the security group used by the App Runner service on port 5432. However, the connection still times out. I've also double-checked that the subnet specified has a route to the internet via a NAT gateway since my RDS instance does not have a public IP. To troubleshoot, I've tried running a simple Node.js script locally that connects to the RDS instance using the same credentials and endpoint, and that works fine. I also checked the VPC connector in App Runner, and it appears to be correctly associated with the service. What could be causing this connection scenario, and how can I resolve it? Any insights would be appreciated! I'd really appreciate any guidance on this. For context: I'm using Javascript on Windows. Has anyone else encountered this? Thanks in advance!