aws-sdk-java-v2-secrets-manager
giuseppe-trisciuoglio/developer-kit
Retrieve, cache, and rotate AWS Secrets Manager credentials in Java 2.x applications with Spring Boot integration.
What is aws-sdk-java-v2-secrets-manager?
This skill provides production-ready patterns for managing application secrets with AWS Secrets Manager in Java services. Use it when replacing hardcoded credentials, loading database or API keys at runtime, adding caching to reduce latency, or integrating secret access into Spring Boot configuration without leaking values.
- Retrieve and deserialize secrets safely from AWS Secrets Manager using AWS SDK for Java 2.x
- Create reusable SecretsManagerClient with explicit region and credential provider configuration
- Cache frequently accessed secrets to reduce latency and API costs
- Handle secret version stages (AWSCURRENT, AWSPENDING) for rotation-aware applications
- Integrate secret access into Spring Boot beans and configuration services
- Validate end-to-end behavior including IAM permissions, KMS access, and failure paths
How to install aws-sdk-java-v2-secrets-manager
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill aws-sdk-java-v2-secrets-manager- AWS SDK for Java 2.x installed and configured
- SecretsManagerClient credentials with appropriate IAM permissions
- KMS permissions if secrets are encrypted with customer-managed keys
- Spring Boot 2.x or 3.x (for Spring integration patterns)
How to use aws-sdk-java-v2-secrets-manager
- 1.Create a SecretsManagerClient bean in your Spring configuration with explicit region and credential provider
- 2.Build a SecretsService layer to retrieve and deserialize secrets at the integration boundary
- 3.Choose a deserialization strategy (typed objects for JSON, string for plain text) and validate the result
- 4.Add caching only where it solves a real problem (frequent reads, latency-sensitive paths, material cost savings)
- 5.Test IAM permissions, KMS access, missing secret, and decryption failure paths before deployment
- 6.Verify secrets are not logged, included in exception messages, or exposed in metrics or debug endpoints
Use cases
- Replace hardcoded database passwords with managed secrets loaded at runtime
- Load third-party API credentials and tokens from Secrets Manager into Spring Boot services
- Cache hot-path secret lookups to reduce Secrets Manager latency during high-traffic periods
- Implement rotation-aware applications that handle AWSPENDING versions during secret rotation workflows
- Wire secret-backed configuration into Spring Boot beans without exposing values in logs or debug endpoints
- Java backend developers building services with AWS Secrets Manager
- Spring Boot application architects designing credential management patterns
- DevOps engineers implementing secret rotation and access control
- AWS Lambda function developers using Java runtime with rotation workflows
aws-sdk-java-v2-secrets-manager FAQ
Use caching when the secret is read frequently, latency matters for startup or request handling, or the cost of repeated lookups is material. Document cache TTL expectations clearly, especially if the secret rotates.
Read secrets through a thin service layer so cache invalidation and retry behavior stay centralized. Understand which callers must tolerate AWSPENDING during verification workflows, and test how the application behaves during stale cache windows or partial rotation failures.
Never log secretString() or include it in thrown exception messages. Avoid surfacing secrets in logs, metrics, or debug endpoints. Keep secret retrieval in infrastructure services rather than controllers or entities.
Use hierarchical secret names that match domain and environment boundaries. Prefer JSON secrets for multi-field credentials such as database connection details, and deserialize them into typed objects.
Handle IAM policy failures, KMS policy failures, region mismatches, deleted versions, and missing secrets. Test these paths before shipping to production.
Full instructions (SKILL.md)
Source of truth, from giuseppe-trisciuoglio/developer-kit.
name: aws-sdk-java-v2-secrets-manager description: Provides AWS Secrets Manager patterns for AWS SDK for Java 2.x, including secret retrieval, caching, rotation-aware access, and Spring Boot integration. Use when storing or reading secrets in Java services, replacing hardcoded credentials, or wiring secret-backed configuration into applications. allowed-tools: Read, Write, Edit, Bash, Glob, Grep
AWS SDK for Java 2.x - AWS Secrets Manager
Overview
Use this skill to manage application secrets with AWS Secrets Manager from Java services.
It focuses on the operational flow that matters in production:
- how to retrieve and deserialize secrets safely
- when to add local caching
- how to integrate secret access into Spring Boot without leaking values into logs or configuration files
Keep large API notes and extended setup details in the bundled references.
When to Use
Use this skill when:
- replacing hardcoded passwords, API keys, or tokens with managed secrets
- loading database credentials or third-party API credentials at runtime
- adding caching to reduce Secrets Manager latency and API cost
- handling secret version stages such as
AWSCURRENTandAWSPENDING - wiring secret access into Spring Boot beans or configuration services
- preparing rotation-aware applications or Lambda rotation workflows
Typical trigger phrases include java secrets manager, spring boot secret, aws secret cache, load db credentials from secrets manager, and rotate secret.
Instructions
1. Model the secret before writing access code
Decide:
- the secret name and path convention
- whether the value is plain text or structured JSON
- which application boundary is allowed to read it
- whether the caller needs the latest value on every request or can tolerate a cache
Prefer JSON secrets for multi-field credentials such as database connection details.
2. Create one reusable client per application configuration
Use a single SecretsManagerClient with explicit region and the default credential provider chain unless the environment requires something more specific.
Keep client creation in configuration code, not in business services.
3. Retrieve and deserialize at the boundary layer
At the integration boundary:
- fetch with
GetSecretValueRequest - deserialize JSON into a typed object or validated map
- convert AWS exceptions into application-level errors
- never log
secretString()or include it in thrown exception messages
4. Add caching only where it solves a real problem
Use caching when:
- the secret is read frequently
- latency matters for startup or request handling
- the cost of repeated lookups is material
Document cache TTL expectations clearly, especially if the secret rotates.
5. Design for rotation and staged versions
If the secret rotates:
- read through a thin service layer so cache invalidation and retry behavior stay centralized
- understand which callers must tolerate
AWSPENDINGduring verification workflows - test how the application behaves during stale cache windows or partial rotation failures
6. Validate end-to-end behavior
Before shipping:
- verify IAM permissions and KMS access
- test missing secret, wrong region, and decryption failure paths
- confirm secrets are not surfaced in logs, metrics, or debug endpoints
- prove database or API clients refresh correctly when credentials rotate
Examples
Example 1: Reusable client and typed secret lookup
@Configuration
public class SecretsConfiguration {
@Bean
SecretsManagerClient secretsManagerClient() {
return SecretsManagerClient.builder()
.region(Region.of("eu-south-2"))
.credentialsProvider(DefaultCredentialsProvider.create())
.build();
}
}
@Service
public class SecretsService {
private final SecretsManagerClient client;
private final ObjectMapper objectMapper;
public SecretsService(SecretsManagerClient client, ObjectMapper objectMapper) {
this.client = client;
this.objectMapper = objectMapper;
}
public DatabaseSecret loadDatabaseSecret(String secretId) throws JsonProcessingException {
GetSecretValueResponse response = client.getSecretValue(
GetSecretValueRequest.builder().secretId(secretId).build()
);
return objectMapper.readValue(response.secretString(), DatabaseSecret.class);
}
}
Example 2: Cache a hot-path secret lookup
public class CachedSecretsService {
private final SecretCache cache;
public CachedSecretsService(SecretsManagerClient client) {
this.cache = new SecretCache(client);
}
public String apiToken(String secretId) {
return cache.getSecretString(secretId);
}
}
Use this pattern only when the application can tolerate the chosen cache refresh behavior.
Best Practices
- Use hierarchical secret names that match domain and environment boundaries.
- Prefer typed JSON deserialization over string parsing scattered across the codebase.
- Keep secret retrieval in infrastructure services rather than controllers or entities.
- Reuse the SDK client and cache instances.
- Combine least-privilege IAM with KMS permissions and CloudTrail visibility.
- Make rotation behavior explicit in code and operational docs.
Constraints and Warnings
- Do not log secret values, serialized secret objects, or decrypted payload fragments.
- Cached values may remain stale during or after rotation depending on TTL and refresh behavior.
- Secret access can fail because of IAM policy, KMS policy, region mismatch, or deleted versions; handle these cases explicitly.
- Automatic rotation is not available for every secret shape or integration.
- Large or frequently changing secrets may not be good candidates for aggressive in-memory caching.
References
references/api-reference.mdreferences/caching-guide.mdreferences/spring-boot-integration.md
Related Skills
aws-sdk-java-v2-coreaws-sdk-java-v2-kmsspring-boot-dependency-injection
Related skills
More from giuseppe-trisciuoglio/developer-kit and the wider catalog.

better-auth
Provides Better Auth integration patterns for NestJS backend and Next.js frontend with Drizzle ORM and PostgreSQL. Use when setting up Better Auth with NestJS backend, integrating Next.js App Router frontend, configuring Drizzle ORM schema, implementing social login (GitHub, Google), adding plugins (2FA, Organization, SSO, Magic Link, Passkey), implementing email/password authentication with session management, or creating protected routes and middleware.

bug-fix-brief
Generates a structured Bug Fix Brief (BFB) to document issue corrections. Includes root cause analysis, repro steps, fix options, and fix checklist. Use when user asks to create a BFB, document a bug fix, or generate a bug correction document.

chunking-strategy
Optimize document chunking for RAG systems with size, overlap, and semantic boundary recommendations.

clean-architecture
Clean Architecture, Hexagonal Architecture, and DDD patterns for Spring Boot 3.5+ applications.

codex
Provides Codex CLI delegation workflows for complex code generation and development tasks using OpenAI's GPT-5.3-codex models, including English prompt formulation, execution flags, sandbox modes, and safe result handling. Use when the user explicitly asks to use Codex for complex programming tasks such as code generation, refactoring, or architectural analysis. Triggers on "use codex", "delegate to codex", "run codex cli", "ask codex", "codex exec", "codex review".

constitution
Creates, updates, validates, and displays the architectural DNA of a project through two shared documents: docs/specs/architecture.md (technology stack, architectural rules, security constraints, AI guardrails) and docs/specs/ontology.md (domain glossary / Ubiquitous Language). Use BEFORE brainstorm as a project setup step, or at any point in the SDD lifecycle to validate specs/tasks against architecture principles. Triggers on 'create constitution', 'update constitution', 'constitution check', 'validate against constitution', 'project principles', 'architectural guardrails', 'setup project architecture', 'define ontology'.