-1

In AWS, made 2 accounts.

  • account 1: A | Deployed EC2
  • account 2: B | Deployed RDS

Want to connect from account 1's EC2 to account 2's RDS, but doesn't work. So enabled VPC flow logs to diagnose where is the problem. The connection between these 2 accounts is using transit gateway. Both side have connected to self VPC with route table.

After did a connection test from A to B via db connect client, tried to find Network Interface ID from A, such as eni-XXXXXXXX belongs to the EC2 instance, in B's CloudWatch Logs Group, can't find its name.

I followed this guide to do, Using AWS VPC Flow Logs to Diagnose Intermittent RDS Connections. But these steps can't resolve my problem, I can't diagnose with it:

Determining your RDS Instance’s Elastic Network ID (ENI)

  1. Use the AWS RDS Console to obtain the instance’s endpoint (this will be in the form [xxx].[region].rds.amazonaws.com).
  2. Use dig or something similar to lookup the IP address of the endpoint. A CNAME is not sufficient, you’ll need the actual IP.
  3. Use the AWS Network Interface Console to search for the IP Address you got, and obtain the Network Interface ID (this will be eni-XXXXXXXX) from the resulting record.

Querying Your Flow Logs

  1. Use the VPC Console to locate your VPC. Go to the Flow Log tab, and click through to the CloudWatch Logs Group.
  2. In the CloudWatch Logs Group, use the search box to find your Network Interface ID.
  3. Click into the record you’ve found, and you’ll see all the traffic for your instance!

How can confirm the network traffic each other correctly?

I found an unknown port in the flow logs.

2 023910321035 eni-12309fdsaj0jf012 ACCOUNT_1_EC2_IP ACCOUNT_2_RDS_IP 45052 31337 6 3 180 1619490209 1619490213 REJECT OK
2 023910321035 eni-12309fdsaj0jf012 ACCOUNT_1_EC2_IP ACCOUNT_2_RDS_IP 45052 31337 6 3 180 1619490209 1619490213 REJECT OK

The port 31337 didn't open. Why it will connect this port?

8
  • 1
    I'd deploy an EC2 in account 2, open up ICMP / ssh, and test with ping / ssh. Check your VPC and transit gateway route tables, security groups on both ends, NACLs.
    – Tim
    Commented Apr 27, 2021 at 1:35
  • @Tim I checked everything you mentioned above. All of them look good. I also tested in account 2 with an EC2 instance. It can connect to the RDS in account 2.
    – Miantian
    Commented Apr 27, 2021 at 2:47
  • @Tim And we aren't using transit gateway route tables but normal route tables. Other accounts work fine. They are using the same configuration method.
    – Miantian
    Commented Apr 27, 2021 at 3:03
  • You need to configure VPC route tables to allow the VPCs to communicate with Transit Gateway, and Transit Gateway route tables to tell it where to route data. Depending on your TG configuration the TG route table may be populated automatically from VPC route propagation but you need to check it.
    – Tim
    Commented Apr 27, 2021 at 3:48
  • 1
    Just ensure ICMP can make it through security groups, AL2 and Ubuntu respond to ping by default. Given the length of the comments here maybe you're better off getting a consultant in to help you. This kind of thing can be fiddly, sometimes some experience means it's done in 2 hours instead of 2 weeks.
    – Tim
    Commented Apr 27, 2021 at 8:57

1 Answer 1

1
  1. Do you really need Transit Gateway? As suggested in the answer to your other question VPC Peering may be enough. If not tell us why.

  2. In that other question you confirmed that your setup in the end worked and you could connect from EC2 to RDS. If you can't now what has changed?

  3. As suggested in the other answer and also by @Tim here in the comment do this:

    • Spin up an EC2 instance in the same Subnet and Security Group as your RDS.
    • Use netcat to listen on the DB port (e.g. 3306 for mysql) and tcpdump to observe the traffic from the "other" EC2.

    Using that figure out if your connectivity works - do you see the incoming packets with tcpdump? Do you see the responses?

1
  • Thank you again. Yes, I confirmed the connection between multiple AWS accounts before. Actually we have many accounts, most of them can connect to the RDS but only one can't. In order to verify where is the trouble, we enabled VPC Flow Logs to check(Thanks to you for the suggestion). And we already designed our network solution with Transit Gateway so we can't change it. I can confirm that the connection from account 2's EC2 is available. But can't from account 1. I tried to use netcat and tcpdump to get something but nothing happened(Added to the bottom of the question).
    – Miantian
    Commented Apr 27, 2021 at 2:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .