https://github.com/aws/aws-secretsmanager-caching-java
The AWS Secrets Manager Java caching client enables in-process caching of secrets for Java applications.
https://github.com/aws/aws-secretsmanager-caching-java
aws-secrets-manager caching java secret
Last synced: 9 months ago
JSON representation
The AWS Secrets Manager Java caching client enables in-process caching of secrets for Java applications.
- Host: GitHub
- URL: https://github.com/aws/aws-secretsmanager-caching-java
- Owner: aws
- License: apache-2.0
- Created: 2018-10-22T23:19:14.000Z (over 7 years ago)
- Default Branch: v2
- Last Pushed: 2025-05-05T12:53:27.000Z (9 months ago)
- Last Synced: 2025-05-08T00:08:00.267Z (9 months ago)
- Topics: aws-secrets-manager, caching, java, secret
- Language: Java
- Homepage:
- Size: 90.8 KB
- Stars: 74
- Watchers: 15
- Forks: 34
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
## AWS Secrets Manager Java caching client
[](https://github.com/aws/aws-secretsmanager-caching-java/actions/workflows/maven.yml)
[](https://codecov.io/gh/aws/aws-secretsmanager-caching-java)
The AWS Secrets Manager Java caching client enables in-process caching of secrets for Java applications.
## Getting Started
### Required Prerequisites
To use this client you must have:
* **A Java 8 development environment**
If you do not have one, go to [Java SE Downloads](https://www.oracle.com/technetwork/java/javase/downloads/index.html) on the Oracle website, then download and install the Java SE Development Kit (JDK). Java 8 or higher is recommended.
An Amazon Web Services (AWS) account to access secrets stored in AWS Secrets Manager and use AWS SDK for Java.
* **To create an AWS account**, go to [Sign In or Create an AWS Account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) and then choose **I am a new user.** Follow the instructions to create an AWS account.
* **To create a secret in AWS Secrets Manager**, go to [Creating Secrets](https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_create-basic-secret.html) and follow the instructions on that page.
* **To download and install the AWS SDK for Java**, go to [Installing the AWS SDK for Java](https://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-install-sdk.html) in the AWS SDK for Java documentation and then follow the instructions on that page.
### Download
You can get the latest release from Maven:
```xml
com.amazonaws.secretsmanager
aws-secretsmanager-caching-java
2.0.0
```
Don't forget to enable the download of snapshot jars from Maven:
```xml
allow-snapshots
true
snapshots-repo
https://aws.oss.sonatype.org/content/repositories/snapshots
false
true
```
### Get Started
The following code sample demonstrates how to get started:
1. Instantiate the caching client.
2. Request secret.
```java
// This example shows how an AWS Lambda function can be written
// to retrieve a cached secret from AWS Secrets Manager caching
// client.
package com.amazonaws.secretsmanager.caching.examples;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
import com.amazonaws.secretsmanager.caching.SecretCache;
/**
* SampleClass.
*/
public class SampleClass implements RequestHandler {
private final SecretCache cache = new SecretCache();
@Override
public String handleRequest(String secretId, Context context) {
final String secret = cache.getSecretString(secretId);
// Use secret to connect to secured resource.
return "Success!";
}
}
```
## License
This library is licensed under the Apache 2.0 License.