Lambda to RDS Connectivity
Hi, I'm wanting to establish connectivity to an RDS instance from some Lambda functions. Lambda functions are autodeployed with serverless framework, so ideally my config would be dynamic. I am currently managing infrastructure with CDK, and have the following resources:
- RDS on Private Isolated subnet in VPC A, managed by CDK
- EC2 instance on public subnet in VPC A, managed by CDK (For access to the RDS from the wider internet)
- (Backend) 4 Lambdas without a VPC (Public), behind an API Gateway in default VPC, managed by serverless deploy
- Frontend hosted on S3 behind Cloudfront, managed by serverless deploy
I'm a bit stumped because I don't want to update my CDK script whenever the lambdas change. Help is much appreciated.
There is no need to update the CDK scripts. All you need to do is attach the functions to some private subnets in the same VPC. Look at this to find out how to reference a CloudFormation Output in your serverless yaml.
I think it would be better to attach the functions to different subnets in the same VPC. In the RDS security group reference the Lambda security group to allow access.
Relevant questions
Lambda to RDS Connectivity
asked a month agoAWS Lambda not able to connect to public RDS instance
asked 2 months agoHow to handle failed lambda functions
asked 3 months agoPackaging Lambda functions into a Cloud formation Template for sharing and deployment
asked 7 months agoRestricting IPs for Lambda functions connected to VPCs
Accepted Answerasked a year agoDeploying Lambda functions from GitHub "serverlessly" with our Code* services
Accepted Answerasked 6 years agoReusing C# Lambda functions
Accepted Answerasked 2 months agoRDS connections in Lambda
Accepted Answerasked 2 months agoCan't connect to an RDS Instance from Lambda (different account tough)
asked 2 years agoscript to update python runtime from 3.6 to 3.9 in lambda functions
Accepted Answerasked 2 months ago
Am I ok to put them in the same Private Isolated subnet as the RDS? Otherwise I can create private subnets on the VPC and put them there. How do I then allow access to the RDS?