Connecting to RDS Instance from Elastic Beanstalk - laravel

This has been killing me all day.
I've set up Elastic Beanstalk, working fine.
Set up RDS, working fine and can access from my laptop.
But when i try to connect to the RDS from my ES application i get a timeout error.
Extra info is that i'm using a Laravel application, connecting to a MYSQL database. All of my environment variables have been loaded and accepted fine.
I'm almost certain it's a security groups setting, but the docs are so tremendously bad for AWS that i haven't got a clue what to do!
Any help?

Answer was to go to Services > VPC
Under the Security section, click Security groups.
Click the RDS group, then Inbound Rules.
Edit, then add a rule:
Select MYSQL, change the port, then the IP should be custom IP and type in the ID of your Elastic Beanstalk security group / groups (No idea why i have 2)

Related

This site can’t be reached for AWS Elastic Beanstalk Environment URL

I was paused an AWS Laravel application from elastic beanstalk by making max instance 0.
And now I want to resume it, and when I made max instance 1, EB create the instance, and I setup the security group to handle ssh port 22 and http port 80, so now the instance is accessible by ssh and all is well, but the environment URL form elastic beanstalk not respond and gives me "This site can’t be reached"
And my security group is
So why I see "This site can't be reached"
Thanks in advance
After some tries I paused and resumed the elastic beanstalk again, and I make rebuild environment, so it working well now
And my security group created automatically by EB to be like this

Not able to connect Amazon Aurora Serverless from SQL client

Today I've created Amazon Aurora Serverless cluster for PostGreSql in us-west-2, ensured the VPC and security groups in
a way that, it should be publicly accessibly. But I'm not able to connect that cluster using the aurora endpoint from my Navicat/PgAdmin4 desktop client. Then I tried from the EC2 instance that are in same security group/vpc as like as Aurora Serverless, then it worked.
From AWS froum,
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.
Source: https://forums.aws.amazon.com/thread.jspa?messageID=862860&tstart=0
Seems it uses an internal AWS networking setup that currently only supports connections from inside a VPC, and it must be the same VPC where the serverless cluster is deployed.
So now basically my question is that,
Is there any workaround to connect Aurora Serverless with any client like Navicat or PgAdmin4?
I found a cool hack that is working perfectly for my development purpose with some tweaks and I know I don't need this on my production environment.
So as we know Aurora Serverless works only inside VPC. So make sure you are attempting to connect to Aurora within the VPC and the security group assigned to the Aurora cluster has the appropriate rules to allow access. As I mention earier that I already have an EC2 instance, Aurora Serverless and a VPC around both. So I can access it from my EC2 but not from my local pc/ local sql client. To fix that I did below two steps.
1. To access from any client(Navicat in my case),
a. First need to add GENERAL db configurations like aurora endpoint host, username, password etc.
b. Then, need to add SSH configuration, like EC2 machine username, hostip and .pem file path
2. To access from project,
First I create a ssh tunnel from my terminal like this way,
ssh ubuntu#my_ec2_ip_goes_here -i rnd-vrs.pem -L 5555:database-1.my_aurora_cluster_url_goes_here.us-west-2.rds.amazonaws.com:5432
Then run my project with db configuration like this way test.php,
$conn = pg_connect("host=127.0.0.1 port=5555 dbname=postgres user=postgres password=password_goes_here");
// other code goes here to get data from your database
if (!$conn) {
echo "An error occurred.\n";
exit;
}
$result = pg_query($conn, "SELECT * FROM brands");
if (!$result) {
echo "An error occurred.\n";
exit;
}
while ($row = pg_fetch_row($result)) {
echo "Brand Id: $row[0] Brand Name: $row[1]";
echo "<br />\n";
}
This question comes up over and over for multiple AWS services (most new ones are VPC only by default). The short answer is - you can hack up something and expose the DB outside of the VPC, but it is not recommended for a production setup. Assuming this is for a dev setup, by all means try the recommendations from [1]. It is for Neptune, but you can do the exact same thing for Aurora.
[1] Connect to Neptune on AWS from local machine

Connecting to Aurora AWS Serverless

I’ve now tried to create a serverless Aurora (MySQL compatible) database and connect to it for two days, and I just can’t seem to get it to work. Supposedly I should have been able to get it up and running in five minutes.
In any case, I created am Aurora Serverless database in the US East (N. Virginia) region (us-east-1), and have been able to connect to it with the AWS Query Editor. I also have an EC2 server in the same region, and have given the Aurora database the same security group (under RDS > Security Group), and in the security group I have opened for MYSQL/Aurora (TCP, 3306) from all sources. When I click the modify button on the database, there is also another (VPC) Security Group listed (rds-launch-wizard-4), which was created automatically. This one I also located under my EC2 dashboard and gave access to all ports from all sources (inbound), and to all ports (outbound). And there is a networking VPC & subnet group, which I don’t know what to do with, if anything.
I try to connect to the database, using this command line command:
mysql -h hest2.cluster-xxxxx.us-east-1.rds.amazonaws.com -P 3306 -u root –p
It generates an error “ERROR 2003 (HY000): Can't connect to MySQL server on” on both my EC2 instance, my local computer and on other online servers.
From the EC2 instance, try doing a telnet on the DB port to test if all your security group settings are applied correctly.
telnet hest2.cluster-xxxxx.us-east-1.rds.amazonaws.com 3306
If the connection does go through, then the issue is with your client code. Cross check that you have wired the right endpoint in your code.
If the telnet connection does not group (I'm guessing that it would not), then it is guaranteed that your security group settings are not set correctly. In order to debug this further, we would need more details on:
The list of vpc security groups associated with your cluster.
The details of each of these vpc security groups (You've mentioned that
you've opened up everything, but I'd like to see the exact rules in
place)
As for laptop and other servers - If they are outside the VPC, then it would not work. Aurora Serverless is accessible only from within the VPC as of now.

java oracle database change notification

I have one application deployed on Red Hat Linux and Oracle 12c.
As part of the application, there is an implementation of Oracle Database Change Notification. Whenever there is a change in the database, that triggers a notification back to the application server. Based on that, the application makes some decisions. Here everything is working well.
Now we are migrating application to amazon EC2 instance with our Red Hat Linux box converted into an EC2 instance and the Oracle Database migrated to cloud. I don’t know what that means, but I do have connection parameters and I'm able to connect though the JDBC driver from my application deployed in the EC2 instance.
Somehow the database change notification functionality is not working in EC2and nothing can be tracked from the application log.
Oracle Database in cloud in aws, which I consider it has to be RDS.
You need to understand the basic on how the application is deployed in aws cloud.
The EC2(with app server) must be in public subnet with security group allowing http/https traffic.
The RDS is kept in private subnet with security group attached which only allows incoming traffic from EC2 instance ( or public subnet).This is general scenario in most of the cases.
The RDS security group only allows the incoming traffic from ec2. but any traffic from your DB (Outgoing traffic) has to be explicitly allowed from the security group attached to Your RDS.
The same traffic needs to be allowed in your Ec2 instance security group.
I am unaware of your specific feature, whether it is supported in AWS RDS or not, you should take a look at AWS RDS Oracle docs

I cannot acess to the website host on Amazon EC2 instance even I think the configuration is right

I have a free Amazon EC2 instance. And I installed Apache web server on it. I have the DNS record for my domain point to the ip for the EC2 instance. I can not access to my website. Then I looked up and allow the http inbound. But I still failed to access my web? What might be the reason. Anybody gives me a clue?
Go to the AWS management console and look at the Security Group the instance is in. Then make sure you have the port open that you are trying to connect to (most likely 80). To open it to the world set the ip range to 0.0.0.0/0 and to open it to a specific ip (like only your house) set it to xxx.xxx.xxx.xxx/32.
That is almost always the reason people have problems connecting when they are new to AWS. I wrote this post, which should help get you setup.

Resources