Connect Elastic Load Balancer instance to back-end database - amazon-web-services

I have an application hosted on Amazon AWS with backend database. Web application is controlled by Elastic Load Balancer with Autoscaling. MySQL databse is on the other instance within the same zone. The problem is that connection could be established only if I add rule in MySQL security group to connect on 3306 from 0.0.0.0. or if I add individual IP address of each instance. However, if I assign "Autoscale security group" or "Load Balancer security group" it doesn't work. Isn't that supposed to work if I assign security group where instances belongs to the MySQL security group?
Thanks,

I've finally solved the issue with the help of Amazon technical support for developers. It turned out that back-end instance is only accessible through the Amazon private IP address. I was always trying to access it through it's public IP address.

AWS allows ingress between two security groups only if they are configured in the same region. For your spcific case, modify the security group settings for the Mysql server allowing in-bound 3306 port traffic from AccountId/OtherSecurityGroup e.g 111122223333/OtherSecurityGroup

Related

AWS EC2 accessible only through load balanced EC2 instances [duplicate]

I have my MongoDB deployed in an EC2 instance, nice and steady. I will (hopefully) have my Elastic Beanstalk load-balanced Web App launched soon using Docker. However, I feel like my Database is too sensitive to dockerize or beastalk-ize, so I wanna keep it in a plain EC2 instance.
My issue is with regard to the security groups. How can I create a security group that will only accept MongoDB traffic (port 27017) from the Elastic Beanstalk? Since EC2 instances will get created and destroyed arbitrarily, maybe I can get the least-common subnet of those?
When you create your Elastic Beanstalk application, you will choose a security group to assign to it's EC2 instances.
For your MongoDB security group, allow traffic on port 27017 for the EB EC2's security group. If done this way, then only EC2 instances using that security group can access the MongoDB instance.
Note, when accessing your MongoDB instance from your EB app's EC2 instance, makes sure you use the private IP address of the MongoDB instance, and not the public IP address. If you use the public IP address, then AWS doesn't recognize the connection as originating from the EB security group and will deny the connection.

Memcached running but ec2 security group settings need to be checked

Hi I'm running memcached on my webserver on an AWS ec2 instance. So it has a public IP address and a private IP address.
I followed the following page to install memcached:
https://www.thefanclub.co.za/how-to/how-install-memcached-on-ubuntu-for-drupal
One step is to "Open firewall port 11211"
My question is what rule should I add to the ec2 security group? I want to know the source ip setting.
Right now in the ec2 security group, Inbound rules, I've added allow 11211 port tcp from source private ip address of the ec2 instance. Is that correct for memcached to work for anonymous users from the internet visiting my website? Thanks!
what rule should I add to the ec2 security group?
No rule at all.
If you are running memcached on the same machine your web server, then you do not need any security group settings for memcached. If the connection never leaves the machine, the security group settings have no impact on it.

AWS security group for inbound traffic

I have two AWS Linux AMI servers.
One with a Node.JS HTTPS server and the second running my Mongo DB.
The only way to connect to my Mongo DB server is through my Node.JS server.
In my in the AWS security group for the Mongo DB server I was able to put the name of the the AWS security group for the Node.JS server in the 'Source' column in the 'Inbound' tab and it allowed connectivity, but I'm wondering what setting the security group actually does?
More specifically, what IP addresses is this allowing?
If you click the 'i' next to Source it states:
I initially resorted to using the "private IP address" for communication between AWS instances because according to AWS documentation,
A private IP address is an IP address that's not reachable over the
Internet. You can use private IP addresses for communication between
instances in the same network (EC2-Classic or a VPC).
But after some discussion (see comments below) it seems the better solution may be to utilize AWS Security Groups. My initially hesitation in using AWS security groups was unfounded.
My fear was that if I added the same security group assigned to my Node.js server to the 'Source' for the inbound traffic tab of my MongoDB server, then my MongoDB server would inherit the same inbound traffic rules (all traffic).
The aforementioned fear is unfounded because setting the inbound source to a security group does NOT inherit the rules, but rather simply allows inbound traffic from any instance that has been assigned to that security group.

Amazon RDS Security Group with Load Balancer IP

We have a setup where our Load Balancer is talking to one of our RDS instances at Amazon. For the Security Group of our RDS instance we have to fill in a IP Address. Only the IP address of the Load Balancer cant be used because it could change. So we should "create a CNAME record for the Load Balancer DNS name". But we can only fill in a IP address into the Security Groups, so there's the problem.
What should be do to keep it secure but also working? Because opening the RDS instance for all ip addresses doesn't seem safe to me.
I contacted AWS directly and was told that currently RDS doesn't support ELB since AWS considers ELB's use case for distributing web traffic only. Here are two links that were provided to me by AWS in case you haven't seen them:
Discussion about why it's not good to load balance to dbs for writes:
Can I use Amazon ELB for my RDS instance for load balancing?
Feature request to AWS - customers are using self managed HAProxy to accomplish:
https://forums.aws.amazon.com/thread.jspa?threadID=58633
The only work around I can think of - if you want to continue on an unsupported design - is to use the subnet IP range that the ELB's are serving assuming you are using VPC.

Amazon RDS and connecting from MySQLWorkbench

I am struggling with this - i've read loads about it but I still cannot see where I am going wrong.
I've installed MySQLWorkBench and connection tests to my RDS fail. I've tested using telnet to my endpoints on port 3306 and they cannot connect either.
I've created the classic public/private subnets within the Amazon VPC, this includes a DBServerSG Security Group which is currently set to Allow ALL inbound traffic and allow ALL outbound traffic (for testing) and i've ensure my RDS instance is set with the right DB Subnet Group.
I don't have a firewall on my client PC either
I STILL can't connect to my RDS Instances, any thoughts?
Edit, I created a second instance to rule out password/user problems
step 1
create a new security rule (or edit an existing one) and add your IP address to gain access to the Amazon Web Service RDS instance.
setp 2
Go to RDS console > security group screen > select or create a new security group. And add your public IP address (don't forget to add the subnet mask for example /32 after the host).
step 3
Then figure out what is the instance address, to do so go to the instance menu and write down the endpoint, port number and principal username:
step 4
now connect to RDS from workbench using a new connection with these Hostname: the endpoint of your RDS instance
Port: the port of your RDS instance
Username: your MySQL username
For further clarification refer to this link for pictorial representation