How can i connect to Aurora serverless in Spring boot - spring

I want to connect aws aurora serverless from local using spring boot.
Because aurora can't public access so i I did the following.
1: create a NLB,
2: Using private IP of aurora serverless to add target group.
i can connect to aurora from my mysql workbench local using loadbalancer url but can't connect when config in datasource in my application.yml file. what is happening.
spring:
datasource:
url: "jdbc:mysql://auroradb-5164fsdafas.elb.ap-southeast 1.amazonaws.com:3306/my_db"
username: admin
password: password

Related

Spring cloud config vault with azure authentication : failed to read config on AKS

I am trying to achieve the following:
Able to use Azure user assigned managed identity(UAMI) to authenticate to vault(deployed on azure) from a spring boot application(deployed within AKS)
Stack : openjdk 8 , spring boot 2.5.4 , spring-cloud-starter-vault-config 3.0.3, AKS
I have hashicorp vault installed on azure. The below document suggest I can use UAMI in this case to authenticate to vault.
referring to https://cloud.spring.io/spring-cloud-vault/reference/html/
Spring boot application config :
application.yml:
server:
port: 8090
spring:
application:
name: my application-service
cloud:
config:
import: vault://secret/somepath_to_secrets
vault:
uri: https://my-vault-uri
scheme: https
namespace: myapp
authentication: AZURE_MSI
azure-msi:
role: pod_identity_role_name
This works a bit ok on my local as the logs says it trying to hit the vault URI mentioned above and make connection and of course I can not test this on local end to end due to azure MSI . I am using user assigned Managed identity(UAMI).
But when i deploy this to Azure Kubernetes cluster , it gives me the following error and doesn't even try to connect to vault. Seems like it is expecting authentication as token:
Error creating bean with name 'clientAuthentication' defined in class path resource
caused by java.lang.IllegalArgumentException: Token(spring.cloud.vault.token) must not be empty
This is not making sense to me as local and AKS logs are totally different. I have root certs in my JKS on both local and AKS .
Could someone please help me on this. I have looked out various documents but all seems to be old.
As per the below document Integrating Hashicorp Vault with Azure AKS using Azure POD Identity - Arctiq, you can integrate your Hashicorp vault with AKS. You can generate an Authentication Token from the AKS to authenticate the Hashicorp vault.
Azure AD Pod Identity allows you to bind Pods to an Azure Identity that is managed outside of your cluster. Vault can be configured to use Azure AD as identity provider, which will enable your containerized applications in AKS to consume secrets in Vault without any code modifications.
Enable Azure AD Pod Identity on your AKS.
Create an Azure Identity.
Deploy the Azure Identity to AKS.
Deploy the Hashicorp vault to AKS
Verify Azure Identity Binding
From inside the pod session, grab the token from Azure Metadata
service and then use the JWT token to authenticate with Vault

Can't connect spring boot app running in docker container in google app engine to google cloud sql?

I have spring boot application, that works in docker container, and database configuration is quiet simple:
spring:
datasource:
url: jdbc:postgresql://35.225.172.41/postgres
username: root
password: somePassword
Docker file is also simple as possible:
FROM adoptopenjdk/openjdk14:slim
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
I find out how to access database when I run application locally. I add my local machine IP address to Authorized networks, and if I run my application locally in docker I have access to google cloud SQL, also can connect to it with DataGrip. But when I deploy my application to google app engine it's can't connect to the database. How can I grant permission to my application to get access to google cloud sql? I dried also add application IP address to authorized networks but IP address is dynamic.
My approach of solving this problem was absolutely wrong. To have an access to google cloud slq I had to use spring-cloud-gcp.
https://github.com/GoogleCloudPlatform/spring-cloud-gcp/tree/main/spring-cloud-gcp-samples/spring-cloud-gcp-sql-postgres-sample
All I need is to add required dependencies (in my case :
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-gcp-dependencies:1.2.8.RELEASE"
}
}
...
dependencies {
implementation 'org.springframework.cloud:spring-cloud-gcp-starter-sql-postgresql'
create google cloud API key .json
and set up application.yml properties:
spring.cloud.gcp.credentials.location 'file:/api_key.json'
spring.cloud.gcp.sql.database-name: postgres
spring.datasource.username: someUsername
spring.datasource.password: somePass
spring.cloud.gcp.sql.instance-connection-name: proj-name:region:slq-instance-name
Database URL is not needed, spring cloud gcp will create it and connect your application to cloud database.

How should I configure application.properties to connect Azure SQL database in spring boot?

I created sample spring boot application with mysql db.now I want to connect Azure SQL database instead of MySQL.how to write application.properties?
Here are the Application.properties:
spring.datasource.url=<JDBC Connection String>
spring.datasource.username=<username>
spring.datasource.password=<password>
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
Replace <JDBC Connect String>, <username>, <password> with your SQL database JDBC connection String, login name and password.
You can copy your Azure database connection String from Azure portal:

Amazon Beanstalk Spring Boot deployment

I am deploying Spring Boot Application in Amazon BeanStalk.
Created a new RDS Postgres instance and connected to that instance using Postgres Client Application. Then created a new database in that. Then Changed database configuration to that instance in my local system Spring boot application. Then I able to connect to that database and use it through the application. But when deployed as a war file in Amazon Beanstalk. It is not working. Showing error as
Unable to obtain JDBC Connection
Any Solution?
Thanks in Adavance

bootstrap.yml and AWS user data

I have Spring Boot based application deployed to AWS EC2 instances. The application is a Spring Cloud Config Client.
I would like to configure the URL to my Spring Cloud Config Server via AWS user data (using Spring Cloud AWS).
I can already access the user data via #Value annotations. However if I try to refer to user data inside bootstrap.yml, it's not able to resolve it.
spring:
application:
name: network-device-service
cloud:
config:
uri: ${SPRING_CONFIG_URI}
Any ideas if this it at all possible in bootstrap.yml?

Resources