AWS Postgres RDS database connection to Spring boot - spring-boot

I have an existing spring boot application built using Gradle and i want this app to be connected to AWS RDS Postgres DB. I could not find any useful links so far to achieve this. Can someone please point me to some helpful link to achieve this ?

There are a couple of things you can check :
Is your network allowing to connecting to the external AWS instances, like firewall. Make sure you are not blocked.
You to use a certificate to connect, make sure you have installed it properly.

Related

How to use anything but Google Shell or Web browser when oauth2.googleapis.com is blacklisted (not sure about this)?

I can not connect to Google Services from client application if it is trying to communicate with oauth2.googleapis.com (which is probably blocked in my corporate network - I dont know how to test it for sure).
I tried BigQuery with JDBC driver in Dbeaver. With basic settings.
User-based login does this:
It generates link for OAUTH. I open the browser and login with the right google account. Then I insert generated code into the Dbeaver and I recieve that AUTH has failed.
Service-based login does this:
It does not want me to visit any webpage. It just tells me:
[Simba][BigQueryJDBCDriver](100004) HttpTransport IO error : oauth2.googleapis.com.
I also tried to use ODBC, where PROXY can be filled in. But no luck.
When I take a look into 'Proxy Options' the proxy port is always rewritten by proxy host. Weird.
This is what happens when i click on 'catalog' or 'dataset' drop-down field. I cant do any further steps.
BUT!
When I set my HTTP PROXY in GCLOUD CLI APP then communication works. And I can call BQ from it.
Does it mean that GCLOUD communicates through HTTP Proxy and DBeaver or ODBC does not? Or does it mean that GCLOUD does not need oauth2.googleapis.com but ODBC and JDBC do and it is blacklisted? I am confused.
We need to migrate from our internal environment to GCP. We would love to use various applications. I would ask for whitelisting oauth2.googleapis.com but i am not sure this is the only problem as GCLOUD app works without any flaws.
I am not-experienced with networking so i am more than happy to update / correct this question or add any info (if you need) to help me understand this issue. Thank you
According to your description, your corporate network is using a Proxy to reach out Internet, this is the reason why gcloud is capable to reach out BigQuery service when Proxy settings are configured in your system; through Cloud SDK Proxy settings or HTTP PROXY environment variable.
You require to setup the proxy settings within the JDBC connection string as described in Simba JDBC driver documentation, e.g.:
jdbc:bigquery:DataSetId=MyDataSetId;ProjectId=MyProjectId;OAuthType=1;ProxyHost=MyProxyHost;ProxyPort=MyProxyPort;ProxyUID=MyProxyUsername;ProxyPWD=MyProxyPassword
This connection string will indicate the Proxy settings to Simba JDBC driver.

Switch jdbc connection after Spring Cloud Config change

After successfully setting up a cloud config server and confirming that all works as expected I ran into this issue but I'm not sure if it's supported or the best way to go.
We follow the database-per-service pattern so as an experiment I committed a dev and staging file containing the db connection details of each service so that if we needed to make changes to the server address and credentials we only needed to do it in the config repo.
I have set this up correctly and I confirm that the changes are indeed being propagated from the config server to the clients.
It was only after doing all of this did I notice that even though the services got the updated database details it DID NOT switch its connection.
Is this possible? The only way I could do this was if I restarted the service and that kinda defeats the purpose of having all of this in place. I tried toying with the connection timeouts but it didn't help. The service was still connected to the previous connection.
So it appears a simple addition of the #RefreshScope to my controller did the trick. Thanks to Spring's David Syer for the insight.

Optimal way to access CloudSQL without the clouds_sql proxy

I'm writing a service (Golang) that is meant to access a CloudSQL database.
The recommended way to connect to the CloudSQL instance is to use the cloud_sql proxy - to authenticate with the database and handle the SSL.
However, for performance and few other reasons I would like to access the database directly using a Golang package that handles the authentication.
Currently, using the database/sql package to initiate a connection to the database won't work because I need to whitelist the machine IP with CloudSQL. But given that I'm using Kubernetes to deploy my application, the origin IP could change at any moment.
I'd love to know if anyone knows what would be the best way of going about solving this problem.
If you're on Postgresql you can use their go library: https://cloud.google.com/sql/docs/postgres/connect-external-app#go
For MySQL see this document:
https://cloud.google.com/sql/docs/mysql/connect-external-app#go
Haven't tested this approach (that would vendor lock me to gcloud) but their documentation tends to be reliable and up to date.

Creating an android studio project to run queries on a google cloud sql server using jdbc driver

I have an cloud sql instance up and running and have made a link using a jdbc driver to the instance ip using android studio project. I can successfully run queries from an ip address that I insert manually into the google cloud sql settings and not any other network. This makes my app accessible only from certain ip addresses. Is there a way i can authenticate my google cloud sql to all ip addresses. I do not wish to use the google app engine if possible as I believe it will only complicate my application. My app works well enough is there an easy way to access my sql from any network having supplied my username and password in the code itself?
You can use the console to authorize 0.0.0.0, which will allow connections from any IP address. However, this is not necessarily a good solution. If you embed your database's username and password in your Android app, it can be found by someone else taking apart the apk. If they do that, they will then have complete access to your database. It is more complicated, but you should put some kind of server in front of your database, and have the user authenticate with that server/application, and only have that server communicate directly with your database.

Cloud computing service with the ability to use JDBC

Is there any cloud computing service like e.g. Google's AppEngine or Amazon's S3 out there, that allows me to use JDBC without using some sort of proxy? I do have a MySQL server, that I can't move into the cloud, so I want to access this server directly via a JDBC connection.
If you can't migrate your database, don't move to the cloud. It would be a performance and security nightmare to have your app communicate with the database over the internet.
To answer your question more specifically:
S3 is a storage platform, so it is irrelevant to your question. Google's App Engine is only designed to interface with it's own storage system.
If you really want to do this you could use a full fledged virtual instance such as Amazon EC2, or Rackspace Cloud.
EDIT
I forgot to mention, Google now offers a MySQL service. I would assume that Java apps use jdbc to connect to it.

Resources