Connect RDS Aurora Postgres SQL from one account to another account using AWS Privatelink(VPC Endpoint) with IAM Authentication in AWS - amazon-rds

I want to connect RDS Aurora Postgres SQL from one account to another account using AWS Privatelink(VPC Endpoint) with IAM Authentication. I have below setup.
Account A:
I have VPC Endpoint service which is pointing to NLB and NLB is redirect request to RDS Aurora Postgres SQL.The VPC Endpoint service has allowed principal for 'Account B'.
Account B:
I have created VPC Endpoint which has pointed to 'Account A' VPC Endpoint service. I have application which is connect my RDS DB using VPC Endpoint dns name as host name in psql command(Instead of RDS Endpoint).
I can able to connect RDS from 'Account B' via VPC Endpoint with above setup using credentials mode(username and password of DB).
But I am unable connect RDS with IAM Authentication. How to connect RDS from different account using VPC Endpoint with IAM Authentication.
Could anyone give me details steps?

Related

EKS node unable to connect to RDS

I have an EKS cluster where I have a Keycloak service that is trying to connect to RDS within the same VPC.
I have also added a inbound rule to the RDS Security Group which allow postgresql from source eksctl-prod-cluster-ClusterSharedNodeSecurityGroup-XXXXXXXXX
When the application tries to connect to RDS i get the following message:
timeout reached before the port went into state "inuse"
I ended up replacing the inbound rule on the RDS Security Group from the eksctl-prod-cluster-ClusterSharedNodeSecurityGroup-XXXXXXXXX with an inbound rule allowing access from the EKS VPC CIDR address instead.

Does cluster endpoint of AWS RDS not allow CNAME?

I registered a cluster url for a specific RDS as CNAME through Route53. When I look up records through nslookup, It's expressed as expected, but I can't connect to database. Was it intentionally blocked by AWS?

Creating RDS MySql Read Replica from aws lambda

I am creating a python script to create read replica. Here is the code i wrote.
import boto3
def lambda_handler(event, context):
client= boto3.client('rds')
client.create_db_instance_read_replica(
DBInstanceIdentifier='database-replica',
SourceDBInstanceIdentifier='database-1',
)
I am getting this error:
errorMessage": "Connect timeout on endpoint URL: \"https://rds.ap-southeast-2.amazonaws.com/\""
I have configured all the IAM roles that i think i needed. Can any one have experience with similar problem.
To access private Amazon VPC resources, such as a Relational Database Service (Amazon RDS) DB instance or Amazon Elastic Compute Cloud (Amazon EC2) instance, associate your Lambda function in an Amazon VPC with one or more private subnets.
To grant internet access to your function, its associated VPC must have a NAT gateway (or NAT instance) in a public subnet.
And ensure your RDS Security Group has a self-reference. [means attaching its own Security Group to itself]
Ref

Aurora serverles V2 connection

I've created an Aurora MySQL serverless db cluster in AWS and I want to connect to it from my computer using mySQL Workbench. I've entered the endpoint as well as master user and password, however when I try to connect , it hangs for about one minute and then it says that cannot connect (no further info is given).
Also trying to ping the endpoint, it resolves the name but don't get any answer.
I've read all the documentation from AWS but I really cannot find how to connect. In the vpc security group I've enabled all inbound and outbound traffic on all ports and protocols. The AWS doc says to enable public access in DB settings but I cannot find such an option.
You can't give an Amazon Aurora Serverless V1 DB cluster a public IP address. You can access an Aurora Serverless V1 DB cluster only from within a virtual private cloud (VPC), based on the Amazon VPC service. For Aurora Serverless V2 you can make a cluster public. Make sure you have the proper ingress rules set up and enable public access in database configuration. For more information, see Using Amazon Aurora Serverless.
https://aws.amazon.com/premiumsupport/knowledge-center/aurora-private-public-endpoints/ .

Not able to connect to PostgreSQL from AWS ECS Fargate containers

I am setting up an infrastructure using Fargate and RDS for my web application.
Here are the basic details of infrastructure.
Fargate and RDS are using same VPC and same Subnet
We have an Application Load Balancer infront of Fargate
Able to access container applications using LB url
Now the problem is, Fargate container application is not able to connect to RDS
Can somebody suggest how to configure security groups or other perimeters to allow containers to connect RDS.
If I change RDS SG configuration with RDS port and IP as 0.0.0.0/0
(Anywhere) container application is able to connect to RDS. But this
we will not be able to do in UAT / PROD
Find the security group ID of your Fargate service. It will look
like sg-ab3123b1252, but with different values after sg-.
In your RDS security group rules, instead of putting a CIDR in your source
field, put the Fargate service security group ID. Port 5432 (assuming you are using the standard postgresql port).
By adding the Fargate security group to your RDS security group rule, you're saying "allow TCP traffic on port 5432 from any resource that uses the Source security group specified".
Check the default VPC group in the docs. That page is required reading anyway, but the section linked has an example of what I'm describing specifically.
You may want to try configuring your VPC IP with RDS port into the RDS SG.
In addition to allowing the Security Group access we also had to grant IAM permissions to the role used by our ECS stuff.

Resources