Connecting to RDS from AWS Pipeline EC2 instance - amazon-web-services

I am having a lot of trouble with this and can't find any solution online that will fix my issue.
The goal is to setup an AWS Pipeline to take CSV data from an S3 bucket and put it into an RDS instance. I have two activies inside of my pipeline: create a table if it doesn't exist, and copy the data to the table. However, the pipeline always fails after it tries to create the table in the RDS instance because it can't connect to it. Here is the error:
errorId: ActivityFailed:NullPointerException
amazonaws.datapipeline.taskrunner.TaskExecutionException: java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. at amazonaws.datapipeline.activity.SqlActivity.runActivity(SqlActivity.java:71) at amazonaws.datapipeline.objects.AbstractActivity.run(AbstractActivity.java:16) at amazonaws.datapipeline.taskrunner.TaskPoller.executeRemoteRunner(TaskPoller.java:136) at amazonaws.datapipeline.taskrunner.TaskPoller.executeTask(TaskPoller.java:105) at amazonaws.datapipeline.taskrunner.TaskPoller$1.run(TaskPoller.java:81) at private.com.amazonaws.services.datapipeline.poller.PollWorker.executeWork(PollWorker.java:76) at private.com.amazonaws.services.datapipeline.poller.PollWorker.run(PollWorker.java:53) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. at private.com.google.common.base.Throwables.propagate(Unknown Source) at amazonaws.datapipeline.database.ConnectionFactory.getConnection(ConnectionFactory.java:192) at amazonaws.datapipeline.database.ConnectionFactory.getConnection(ConnectionFactory.java:177) at amazonaws.datapipeline.database.ConnectionFactory.getRdsDatabaseConnection(ConnectionFactory.java:161) at amazonaws.datapipeline.database.ConnectionFactory.getConnection(ConnectionFactory.java:73) at amazonaws.datapipeline.activity.SqlActivity.runActivity(SqlActivity.java:63) ... 7 more Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:527) at com.mysql.jdbc.Util.handleNewInstance(Util.java:404) at com.mysql.jdbc.Util.getInstance(Util.java:387) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:917) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860) at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2330) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2083) at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:806) at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:527) at com.mysql.jdbc.Util.handleNewInstance(Util.java:404) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328) at private.com.amazonaws.services.datapipeline.database.DriverShim.connect(DriverShim.java:26) at java.sql.DriverManager.getConnection(DriverManager.java:571) at java.sql.DriverManager.getConnection(DriverManager.java:187) at amazonaws.datapipeline.database.ConnectionFactory.connect(ConnectionFactory.java:203) at amazonaws.datapipeline.database.ConnectionFactory.getConnection(ConnectionFactory.java:187) ... 11 more Caused by: java.lang.NullPointerException at com.mysql.jdbc.ConnectionImpl.getServerCharset(ConnectionImpl.java:2997) at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1865) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1228) at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2253) at com.mysql.jdbc.Co
One thing to note is that the pipeline is setup in us-east-1, but I have the RDS and EC2 going into us-east-2. I thought I set it up correctly though.
The ec2 instance that is created by the pipeline is set to go into the same subnet as the rds instance. The rds instance has a security group that allows all incoming traffic from the security group of the ec2 instance. The ec2 instance is created with a security group that allows all outgoing traffic. I also made sure the Ec2 instance that is created ends up in the same region as the rds.
It doesn't make much sense to me that this doesn't work because I can manually create an ec2 instance with the same security & subnet settings and connect to the database using telnet <rds endpoint> 3306.
I do not have much experience with AWS so any help is appreciated. Thanks.

Related

AWS DMS. Endpoint connection fails in replication instance (Error: 1020912) still persist

Test Endpoint failed: Application-Status: 1020912, Application-Message: Failed to connect Network error has occurred, Application-Detailed-Message: RetCode: SQL_ERROR SqlState: 08001 NativeError: 101 Message: [unixODBC]could not connect to server: No route to host Is the server running on host "xxx.ap-southeast-1.rds.amazonaws.com" (192.168.0.31) and accepting TCP/IP connections on port 5432?
I researched from the latest topic about this issue and documentations.
I'm sure you gonna ask me to check networking things.
I have checked everything try to provision the ec2 to check the connectivity such as rtb, sg, acl.
Sure my ec2 can connect to RDS.
I tested further by provision DMS instance v3.4.7 in the same subnet, same sg as the ec2 that I have tested. So it always show the error that I mention earlier.
The db is a source endpoint with RDS postges 12. I do this the same with RDS aurora postges 13 compatible.
Now I have no idea and need some help if someone has the same issue here.
Thanks.

Kafka connector Failing to connect AWS MSK

I am trying to configure MSK connect in AWS and the below is the configuration.
INFO [AdminClient clientId=adminclient-1] Metadata update failed (org.apache.kafka.clients.admin.internals.AdminMetadataManager:235)
[Worker-02003b81ffe0ee9c3] [2022-06-02 14:26:40,955] INFO [AdminClient clientId=adminclient-1] Metadata update failed (org.apache.kafka.clients.admin.internals.AdminMetadataManager:235)
[Worker-02003b81ffe0ee9c3] org.apache.kafka.common.errors.TimeoutException: Call(callName=fetchMetadata, deadlineMs=1654180000954, tries=1, nextAllowedTryMs=1654180001055) timed out at 1654180000955 after 1 attempt(s)
As per https://aws.amazon.com/premiumsupport/knowledge-center/msk-connector-connect-errors/ I have opened all traffic for the MSK connector to be able to reach the msk cluster, yet I notice timeout errors.
The connector and the cluster are both in same subnets and uses same security group ID. I ma able to telnet to the broker from a VM in the same subnet.
Note: I have plaintext enabled and no authentication. I have also given proper IAM permission and role attached. This is verified.
Adding the solution in case if it helps someone.
https://docs.aws.amazon.com/msk/latest/developerguide/mkc-tutorial-setup.html
I had to create a vpc endpoint as mentioned in the above doc and also associate the subnet route tables that my kafka uses.
Additionally also make sure your SG's have correct inbound and outbound rules

Can't add private IP (VPC) to new Google Cloud SQL instance with gcloud

I've being trying to create a new CloudSQL instance with a private IP attached from the get go. The only thing documentation hints me is to add a VPC network. I'm trying to add the default one.
First I'm enabling the correct APIs / services to my project:
gcloud services enable servicenetworking.googleapis.com servicemanagement.googleapis.com --project=my-project
Then I'm trying to create the CloudSQL instance:
gcloud beta sql instances create cloudsql-instance-name --region=europe-west1 --project=my-project --network=projects/my-project/global/networks/default
However this gives me this non descriptive error:
ERROR: (gcloud.beta.sql.instances.create) [INTERNAL_ERROR] Failed to create subnetwork. Please create Service Networking connection with service 'servicenetworking.googleapis.com' from consumer project '1234567890' network 'default' again.
Two questions:
Is this the correct way to add a private IP to an instance upon creation? Or are there other ways?
Why is it giving me this error and how can I resolve?
Thanks!
You need to create an "Allocated IP ranges for services" and a "Private connections to services" inside the VPC that you want to have CloudSQL Instance. (In your case is "default" VPC). Once you have both you should be able to create the MYSQL Instance.

Cannot connect to aws redshift

I created a redshift in aws console. the I went to cluster created and based on the information I got in the console I used them in SQL Workbench/J.
To set up sql workbench/J I used the following:
https://docs.aws.amazon.com/redshift/latest/mgmt/connecting-using-workbench.html
So here is my setup:
Now when I try to connect to it I get the following:
Any idea how I can fix it or what is going on?
UPDATE
I also gave inbound security group of the VPC which I had my redshift in full access to the IP address I am conncting and the same issue
Also here is the full logs:
2018-01-18 16:39:36 ERROR Error connecting to the database using
URL=jdbc:redshift://hamedtest.cb1dy4xxxxxxxxxxx [Amazon](500150) Error
setting/closing connection: Connection timed out: connect. [SQL
State=HY000, DB Errorcode=500150]
java.sql.SQLException: [Amazon](500150) Error setting/closing
connection: Connection timed out: connect.
at com.amazon.redshift.client.PGClient.connect(Unknown Source)
at com.amazon.redshift.client.PGClient.<init>(Unknown Source)
at com.amazon.redshift.core.PGJDBCConnection.connect(Unknown Source)
at com.amazon.jdbc.common.BaseConnectionFactory.doConnect(Unknown Source)
at com.amazon.jdbc.common.AbstractDriver.connect(Unknown Source)
at com.amazon.redshift.jdbc.Driver.connect(Unknown Source)
at workbench.db.DbDriver.connect(DbDriver.java:513)
at workbench.db.ConnectionMgr.connect(ConnectionMgr.java:255)
at workbench.db.ConnectionMgr.getConnection(ConnectionMgr.java:182)
at workbench.gui.components.ConnectionSelector.doConnect(ConnectionSelector.java:22
7)
Caused by: com.amazon.support.exceptions.GeneralException: [Amazon](500150)
Error setting/closing connection: Connection timed out: connect.
Did you choose "Publicly accessible" YES (radio button) when creating your cluster? If that is set to NO then you can only access the cluster from inside your VPC.
You easily change this in the console by navigating to the cluster, clicking the Cluster ˅ button, clicking Modify. Then change the "Publicly accessible" selection and click the blue Modify button.

JHipster - Issue Deploy Jhipster Registry in AWS Beanstalk

I am working with a Microservices App with JHipster and I want deploy it in AWS Beanstalk. I had tried in diferent ways deploy it the Registry in AWS Beanstalk but it was unsuccessfully. The Registry does not start, not work and it not connect with the microservices.
When I run the app locally, all works fine, It just happen when I deploy it on AWS Beanstalk.
I had tried and looked for all diferent ways to solve it, but I can not find de problem with de Registry. I had tried these solutions without success:
Change the Ngix port(5000,8081)
Verify the Maven Package to Production
Configure the Security Group on EC2 Instance
Open all ports in EC2 Instance
It is the log:
<i>2017-05-04 14:25:51.705 ERROR 25337 --- [et_localhost-15] c.n.e.cluster.ReplicationTaskProcessor : Network level connection to peer localhost; retrying after delay
com.sun.jersey.api.client.ClientHandlerException: java.net.SocketTimeoutException: Read timed out
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187)
at com.netflix.eureka.cluster.DynamicGZIPContentEncodingFilter.handle(DynamicGZIPContentEncodingFilter.java:48)
at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27)
at com.sun.jersey.api.client.Client.handle(Client.java:652)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570)
at com.netflix.eureka.transport.JerseyReplicationClient.submitBatchUpdates(JerseyReplicationClient.java:116)
at com.netflix.eureka.cluster.ReplicationTaskProcessor.process(ReplicationTaskProcessor.java:71)
at com.netflix.eureka.util.batcher.TaskExecutors$BatchWorkerRunnable.run(TaskExecutors.java:187)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:158)
at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:82)
at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:271)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)</i>
I had multiple problems deploying jhipster registry on Aws EB. At last I tried deploying it as a docker image. Try this steps
Do mvn package docker:build
Copy the DockerFile and the war file to a folder and select both the files to create a zip file
Go to EB-Select Docker as the web server from the dropdown with single
instance (Jhipster recommends single instance for jhipster-registry so avoid load balancer)
If you're using VPC then make sure you select at least one public subnets (It took me days to figure out this step) ref: link