Combine AWS Lambda with Aurora Serverless - amazon-web-services

Is it possible to access Aurora Serverless DB from AWS Lambda?
In my case I have a Flutter mobile application which is communicating with Lumen micro framework through RESTful API. For DB I use MySQL.
After creating AWS Aurora cluster, can I connect to it like to a normal MySQL DB connection?
DB_CONNECTION=mysql
DB_HOST=my.awshost.com
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
I am relatively new to AWS. I've been only using EC2 so far. Therefore, I am trying to getting more familiar with Serverless concept.
Any help is appreciated.

Yes, you can access like other service but there is limitation of Serverless DB, it can only accessible within VPC, so you should define Lambda in the same VPC and configure networking.
Limitations of Aurora Serverless
Aurora with MySQL version 5.6 compatibility
Aurora with PostgreSQL version 10.7 compatibility
The port number for connections must be:
3306 for Aurora MySQL
5432 for Aurora PostgreSQL
You can't give an Aurora Serverless DB cluster a public IP address. You can access an Aurora Serverless DB cluster only from within a virtual private cloud (VPC) based on the Amazon VPC service.
Each Aurora Serverless DB cluster requires two AWS PrivateLink endpoints. If you reach the limit for PrivateLink endpoints within your VPC, you can't create any more Aurora Serverless clusters in that VPC. For information about checking and changing the limits on endpoints within a VPC, see Amazon VPC Limits.
You can't access an Aurora Serverless DB cluster's endpoint through an AWS VPN connection or an inter-region VPC peering connection.
aurora-serverless
You can explore getting-started-with-the-amazon-aurora-serverless-data-api for configuration lambda with Serverless DB.

Related

Can AWS amplify connect to a private RDS resource

I am building a webapp using NextJS. This app will have a backend with datastore that I am planning to use as AWS RDS PSQL. This RDS instance will be private within a VPC and not publicly available, now in AWS Amplify, I don't see any options for VPC, so was wondering on how the NextJS backend code connect to AWS RDS instance?

AWS MSK - Debezium Postgres Connector for AWS RDS - Failed to Connect

I'm currently facing the following issue when using AWS MSK Connector (Debezium Postgres Connector)
[Worker-0509fac07b9701a23] [2022-01-19 04:55:28,759] ERROR Failed testing connection for jdbc:postgresql://debezium-cdc.fac07b9701a2.ap-south-1.rds.amazonaws.com:5432/ecommerce with user 'debezium' (io.debezium.connector.postgresql.PostgresConnector:133)
I've test AWS MSK Connector using Kafka Clients on EC2, I'm able to produce & consume messages. I've also setup AWS MSK S3 Sink Connector, that is working as well.
I've double checked the security groups config for AWS RDS, I'm able to connect to it from EC2.
I'm not sure whats causing this issue.
Here's the Connector Configuration
connector.class=io.debezium.connector.postgresql.PostgresConnector
tasks.max=1
database.hostname=debezium-cdc.fac07b9701a2.ap-south-1.rds.amazonaws.com
database.port=5432
database.dbname=ecommerce
database.user=debezium
database.password=password
database.history.kafka.bootstrap.servers=b-2.awskafkatutorialclust.awskaf.c4.kafka.ap-south-1.amazonaws.com:9094,b1.awskafkatutorialclust.awskaf.c4.kafka.ap-south-1.amazonaws.com:9094,b-3.awskafkatutorialclust.awskaf.c4.kafka.ap-south-1.amazonaws.com:9094
database.server.id=1
database.server.name=debezium-cdc
database.whitelist=ecommerce
database.history.kafka.topic=dbhistory.ecommerce
include.schema.changes=true
key.converter=org.apache.kafka.connect.json.JsonConverter
value.converter=org.apache.kafka.connect.json.JsonConverter
You need to set up AWS RDS Database Publicly accessible: No.
Because your AWS MSK is in a private network (VPC) and it can not connect to public Databases (Read more: https://docs.aws.amazon.com/vpc/latest/userguide/how-it-works.html).
Please try to change your RDS Database Postgres Publicly accessible: No.
And create MSK connect again.
(make sure that your AWS RDS Database is the same VPC, Security Group as your AWS MSK.)
Anyway, If you want to connect with your private AWS RDS Database, you need to do about bastion host (Read more: https://aws.amazon.com/premiumsupport/knowledge-center/rds-connect-ec2-bastion-host/).

I can't enable "Public access" config in AWS Aurora cluster

In the documentation shows that i should can turn on the "Public Access" in RDS Aurora database but I can't see this setting.
This is the screenshot of another RDS Instance (Not Aurora)
Anyone have any idea to fix that?
Thanks!
You are using an Aurora Serverless cluster. The publicly accessible option is only available for provisioned (non-serverless) clusters. Per the note at the bottom of the page here
Note: You can't give an Amazon Aurora Serverless DB cluster a public IP address. You can access an Aurora Serverless DB cluster only
from within a virtual private cloud (VPC), based on the Amazon VPC
service. For more information, see Using Amazon Aurora Serverless.

AWS API to query RDS database

Is there any API to query a standard AWS RDS without using an SQL client? I see that there is a data API available for serverless Aurora databases (https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) but it doesn't work for all RDS types and is not available in all regions at the moment either.
Due to internal firewall rules port 3306 is blocked so I'm looking for another way to talk to an RDS (running the RDS on port 443 has been suggested but is a non-trivial work-around).
Currently the Data API for Aurora Serverless (https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) seems to be the only option.
There does not appear to be any equivalent API for standard Aurora databases.

List of AWS services that don’t require a VPC to run

Google failed me again or may be I wasnt too clear in my question.
Is there an easy way or rather how do we determine what services are VPC bound and what services are non-vpc ?
For example - EC2, RDS require a VPC setup
Lambda, S3 are publicly available services and doesn't need a VPC setup.
The basic services that require an Amazon VPC are all related to Amazon EC2 instances, such as:
Amazon RDS
Amazon EMR
Amazon Redshift
Amazon Elasticsearch
AWS Elastic Beanstalk
etc
These resources run "on top" of Amazon EC2 and therefore connect to a VPC.
There are also other services that use a VPC, but you would only use them if you are using some of the above services, such as:
Elastic Load Balancer
NAT Gateway
So, if you wish to run "completely non-vpc", then avoid services that are "deployed". It means you would use AWS Lambda for compute, probably DynamoDB for database, Amazon S3 for object storage, etc. This is otherwise referred to as going "serverless".