I am trying to doa POC to see how we can connect AWS Keyspace from a springboot application. I running it from my local desktop.
I am using IAM user accesskey/secret and using datastax and aws java sdk dependency.
application.properties
aws.accessKey=ACCESS_KEY
aws.secretKey=SECRET_KEY
aws.region=us-east-2
aws.keyspace.endPoint=cassandra.us-east-2.amazonaws.com
aws.keyspace.name=test_keyspace
I have also created a bean of AmazonKeyspace using BasicAWSCredentials and AmazonKeyspaceClientBuilder using the above properties. I have doubt about this endpoint, if this is correct or not
but when I am running the application, it's failing with AllNodesFailedException. Can you please let me know how to resolve this issue ? I am not sure if I missing something for this.
To work with Keyspace in a Java project, it's recommended that you use software.amazon.awssdk.services.keyspaces.KeyspacesClient, which is AWS SDK for V2. AWS Java V1 is on the path to deprecation:
https://aws.amazon.com/blogs/developer/announcing-end-of-support-for-aws-sdk-for-java-v1-x-on-december-31-2025/
You need to do a few steps:
Create an application.conf file that references the JKS file. See below.
You must create a Cassandra Java client driver (JKS) file. This file is a secure file format used to hold certificate information for Java applications. This is required to make a connection to Amazon Keyspaces. For more information, see the following documentation topic: https://docs.aws.amazon.com/keyspaces/latest/devguide/using_java_driver.html.
You will need that application.conf file. Here is the contents. Notice it references the JKS file.
To work with KeyspacesClient and the required CqlSession object, use the code below.
To handle creds, see the Java V2 dev guide here: Default credentials provider chain.
You will also need a movies.json file for the full example. You can find that here:
https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/resources/sample_files
To run the full example in Java V2, run this code. This will get your familiar with the V2 KeyspacesClient.
See:
https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javav2/example_code/keyspaces/src/main/java/com/example/keyspace/ScenarioKeyspaces.java
Note this example is too big to post here.
I just ran this and it works...