Connecting to RDS from EC2

2019-08-10 17:28发布

问题:

This is a bit of a basic question, I don't have much experience of AWS (Azure is my usual bag!).

When connecting to an RDS instance from and EC2 instance using connection string such as : xxx.xxxxxx.eu-west-1.rds.amazonaws.com:1433 and both the RDS and EC2 are in the same VPC will there be bandwidth charges for that connection? The EC2 can only access the RDS when the RDS IP address is added to the security group.

Also, is the traffic routed over the internet or is there some way to configure traffic over some sort of virtual LAN? If so could someone point me in the direction of how that works?

Does this configuration sound correct?

Thanks for your help. Carl

回答1:

When connecting to an RDS instance from and EC2 instance using connection string such as : xxx.xxxxxx.eu-west-1.rds.amazonaws.com:1433 and both the RDS and EC2 are in the same VPC will there be bandwidth charges for that connection?

The bandwidth charges are the same as data transfer between two EC2 instances in the same VPC. That is, there will be no charge for data transfer within the same availability zone, and will be charged $0.01 per GB for data transferred between availability zones.

The EC2 can only access the RDS when the RDS IP address is added to the security group.

You should enable inbound access from the EC2 security group associated with your EC2 instance, instead of the EC2 IP address.

Also, is the traffic routed over the internet or is there some way to configure traffic over some sort of virtual LAN? If so could someone point me in the direction of how that works?

The VPC (Virtual Private Cloud) is the virtual LAN you are looking for. All traffic between instances and services within your VPC stays within your VPC. Communication within your VPC does not go out to the internet.

Since you mentioned you are coming from an Azure background, you should try to map your knowledge of Azure services to the corresponding AWS services. I believe an "Azure Virtual Network" is basically the same thing as an AWS VPC.



回答2:

You can give permission to your ec2 instance ip address in your RDS security group.

Which database you used? If you are using mysql then ping from server terminal:

mysql -h<<hostname>> -u<<username>> -p<<password>>