PluginBench
Skill
Review
Audit score 70

aws-sdk-java-v2-core

giuseppe-trisciuoglio/developer-kit

AWS SDK for Java 2.x client setup with credential resolution, HTTP tuning, timeouts, retries, and testing patterns.

What is aws-sdk-java-v2-core?

Provides production-safe patterns for configuring AWS SDK for Java 2.x service clients, including credential and region resolution, HTTP client tuning, and lifecycle management. Use when creating or hardening AWS service clients, wiring Spring Boot beans, debugging auth issues, or choosing between sync and async clients.

  • Configure sync and async AWS service clients with explicit timeouts and retry strategies
  • Resolve credentials and regions using DefaultCredentialsProvider with environment-aware defaults
  • Tune HTTP clients (ApacheHttpClient for sync, NettyNioAsyncHttpClient for async) with connection pools and concurrency limits
  • Wire clients as Spring Boot singleton beans with proper lifecycle management
  • Verify credential and region resolution at startup using STS caller identity checks
  • Handle SDK exceptions at integration boundaries and distinguish retryable from auth/quota failures

How to install aws-sdk-java-v2-core

npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill aws-sdk-java-v2-core
Prerequisites
  • AWS SDK for Java 2.x on the classpath
  • Java 8 or later
  • AWS credentials configured (environment variables, shared config, SSO, or IAM role)
  • Spring Boot (optional, for bean wiring examples)
Claude Code
Cursor
Windsurf
Cline

How to use aws-sdk-java-v2-core

  1. 1.Choose sync or async client type based on your workload (sync for request/response, async for concurrency)
  2. 2.Configure DefaultCredentialsProvider and explicit region using Region.of() or environment detection
  3. 3.Set HTTP client builder with connection limits, timeouts, and read/write durations
  4. 4.Apply ClientOverrideConfiguration with apiCallAttemptTimeout and apiCallTimeout values
  5. 5.Wire the client as a Spring Boot @Bean singleton or application-level dependency
  6. 6.Call StsClient.getCallerIdentity() at startup to verify credentials and region resolve correctly
  7. 7.Catch SdkException at integration boundaries and log request context without secrets
  8. 8.Run integration tests against LocalStack or sandbox before shipping to production

Use cases

Good for
  • Creating S3Client or DynamoDbClient with production timeout and retry settings in Spring Boot
  • Configuring SqsAsyncClient for high-concurrency message processing with backpressure
  • Debugging credential resolution failures by calling StsClient.getCallerIdentity() at startup
  • Setting up multi-account access by overriding DefaultCredentialsProvider for specific profiles
  • Running integration tests against LocalStack or sandbox accounts before deployment
Who it's for
  • Java backend engineers building AWS integrations
  • Spring Boot application developers wiring AWS service clients
  • DevOps engineers hardening client configuration for production
  • QA engineers testing credential and region resolution in CI/CD pipelines

aws-sdk-java-v2-core FAQ

Should I create a new client per request or reuse one?

Reuse one SDK client per service and configuration profile. Creating clients per request is expensive and defeats connection pooling and credential caching.

How do I choose between sync and async clients?

Use sync clients (S3Client, DynamoDbClient) for straightforward request/response flows. Use async clients (S3AsyncClient, SqsAsyncClient) for high concurrency, streaming, or when you need backpressure handling.

What is DefaultCredentialsProvider and when should I override it?

DefaultCredentialsProvider checks environment variables, shared AWS config, SSO, and IAM roles in order. Override only for multi-account access, test isolation, or profile switching; otherwise use the default.

How do I verify credentials and region are correct at startup?

Call StsClient.getCallerIdentity() in a @PostConstruct method or startup hook. Log the ARN to confirm authentication and fail fast if credentials are missing or invalid.

What timeouts should I set for production?

Set apiCallAttemptTimeout (per attempt, e.g., 10s) and apiCallTimeout (total request, e.g., 30s) explicitly. Tune based on service SLAs and idempotency; excessive retries amplify throttling.

Full instructions (SKILL.md)

Source of truth, from giuseppe-trisciuoglio/developer-kit.


name: aws-sdk-java-v2-core description: Provides AWS SDK for Java 2.x client configuration, credential resolution, HTTP client tuning, timeout, retry, and testing patterns. Use when creating or hardening AWS service clients, wiring Spring Boot beans, debugging auth or region issues, or choosing sync vs async SDK usage. allowed-tools: Read, Write, Edit, Bash, Glob, Grep

AWS SDK for Java 2.x Core Patterns

Overview

Use this skill to set up AWS SDK for Java 2.x clients with production-safe defaults.

It focuses on the decisions that matter most:

  • how credentials and region are resolved
  • how to configure sync and async HTTP clients
  • how to apply timeouts, retries, lifecycle management, and tests

Keep SKILL.md focused on setup and delivery flow. Use the references/ files for deeper API details and expanded examples.

When to Use

  • Creating or hardening AWS SDK for Java 2.x service clients
  • Wiring Spring Boot beans for AWS integration
  • Debugging auth, region, or credential issues
  • Choosing between sync (S3Client, DynamoDbClient) and async (S3AsyncClient, SqsAsyncClient) clients

Instructions

1. Select the service client type

  • Sync clients (S3Client, DynamoDbClient) for request/response flows
  • Async clients (S3AsyncClient, SqsAsyncClient) for concurrency, streaming, or backpressure
  • Reuse one client per service and configuration profile

2. Configure credential and region resolution

Use DefaultCredentialsProvider with environment-aware defaults:

  • local dev: shared AWS config, SSO, or environment variables
  • CI/CD: web identity or injected environment variables
  • AWS runtime: ECS task roles, EKS IRSA, or EC2 instance profiles

Override only for multi-account access, test isolation, or profile switching.

Verify: Call StsClient.getCallerIdentity() at startup to confirm credentials resolve.

3. Configure HTTP client, timeouts, and retries

Set production values explicitly:

  • API call timeout and attempt timeout
  • connection timeout and max connections or concurrency
  • retry strategy aligned with service quotas and idempotency

Use ApacheHttpClient for sync and NettyNioAsyncHttpClient for async.

Verify: Confirm timeouts and retry behavior under failure conditions.

4. Wire clients as application-level dependencies

In Spring Boot:

  • expose clients as @Bean singletons
  • inject through constructors
  • keep credential and region in configuration files

Verify: Check clients are not created inside hot execution paths.

Close custom HTTP clients and SDK clients during shutdown if lifecycle is not managed automatically.

5. Handle failures at integration boundaries

At the boundary layer:

  • catch SdkException or service-specific exceptions
  • distinguish retryable failures from auth, quota, and validation failures
  • log request context, never secrets or raw credentials

6. Run integration tests before shipping

  • verify region and caller identity in the target environment
  • run tests against LocalStack, Testcontainers, or a sandbox account
  • use @PostConstruct in Spring Boot configuration to fail fast on startup if credentials are missing
StsClient stsClient = StsClient.builder().build();
GetCallerIdentityResponse identity = stsClient.getCallerIdentity();
// Logs: Successfully authenticated as: {identity.arn()}

Examples

Example 1: Spring Boot sync client with explicit HTTP and timeout settings

@Configuration
public class AwsClientConfiguration {

    @Bean
    S3Client s3Client() {
        return S3Client.builder()
            .region(Region.of("eu-south-2"))
            .credentialsProvider(DefaultCredentialsProvider.create())
            .httpClientBuilder(ApacheHttpClient.builder()
                .maxConnections(100)
                .connectionTimeout(Duration.ofSeconds(3)))
            .overrideConfiguration(ClientOverrideConfiguration.builder()
                .apiCallAttemptTimeout(Duration.ofSeconds(10))
                .apiCallTimeout(Duration.ofSeconds(30))
                .build())
            .build();
    }
}

Example 2: Async client for high-concurrency workloads

SqsAsyncClient sqsAsyncClient = SqsAsyncClient.builder()
    .region(Region.US_EAST_1)
    .credentialsProvider(DefaultCredentialsProvider.create())
    .httpClientBuilder(NettyNioAsyncHttpClient.builder()
        .maxConcurrency(200)
        .connectionTimeout(Duration.ofSeconds(3))
        .readTimeout(Duration.ofSeconds(20)))
    .overrideConfiguration(ClientOverrideConfiguration.builder()
        .apiCallTimeout(Duration.ofSeconds(30))
        .build())
    .build();

Best Practices

  • Default to DefaultCredentialsProvider unless a project requirement says otherwise.
  • Keep region selection explicit for server-side services.
  • Reuse SDK clients instead of constructing them per request.
  • Tune retries with service quotas and idempotency in mind.
  • Put business mapping on top of the SDK, not inside controllers.
  • Keep integration tests close to the configuration that creates the clients.
  • Move deep service-specific examples to dedicated skills such as S3, DynamoDB, Bedrock, or Secrets Manager.

Constraints and Warnings

  • Do not embed access keys or session tokens in source code, examples, or configuration files.
  • Static credentials are acceptable only for tightly scoped local tests.
  • Missing region or invalid credential resolution often fails only at first call, so verify startup assumptions explicitly.
  • Async clients require lifecycle management for the underlying HTTP resources.
  • Excessive retries can amplify throttling and increase latency.
  • Proxy, TLS, and metric publisher APIs can vary by chosen HTTP stack and SDK version; adapt examples to the versions already used by the project.

References

  • references/api-reference.md
  • references/best-practices.md
  • references/developer-guide.md

Related Skills

  • aws-sdk-java-v2-secrets-manager
  • aws-sdk-java-v2-s3
  • aws-sdk-java-v2-dynamodb
  • aws-sdk-java-v2-bedrock