Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
giuseppe-trisciuoglio avatar

Aws Sdk Java V2 Kms

  • 1.6k installs
  • 311 repo stars
  • Updated June 22, 2026
  • giuseppe-trisciuoglio/developer-kit

aws-sdk-java-v2-kms is an agent skill that provides aws key management service (kms) patterns using aws sdk for java 2.x. use when creating/managing encryption keys, encrypting/decrypting data, generating data keys, digi

About

aws-sdk-java-v2-kms is an agent skill from giuseppe-trisciuoglio/developer-kit that provides aws key management service (kms) patterns using aws sdk for java 2.x. use when creating/managing encryption keys, encrypting/decrypting data, generating data keys, digital signing, key rotati. # AWS SDK for Java 2.x - AWS KMS (Key Management Service) ## Overview Provides AWS KMS patterns using AWS SDK for Java 2.x. Covers key management, encryption/decryption, envelope encryption, digital signatures, and Spring Boot integration. ## Instructions 1. **Set Up IAM Permissions** - Grant kms:* actions with least privilege 2. **Create KMS C Developers invoke aws-sdk-java-v2-kms during build/backend work for backend & apis tasks. The skill documents triggers, prerequisites, and step-by-step workflows grounded in SKILL.md. Compatible with Claude Code, Cursor, and Codex agent runtimes that load marketplace skills.

  • AWS SDK for Java 2.x - AWS KMS (Key Management Service)
  • 1. **Set Up IAM Permissions** - Grant kms:* actions with least privilege
  • 2. **Create KMS Client** - Instantiate KmsClient with region and credentials
  • 3. **Create Keys** - Use createKey() → **Verify key state is ENABLED before proceeding**
  • 4. **Set Key Policies** - Define key usage permissions → **Test access before production**

Aws Sdk Java V2 Kms by the numbers

  • 1,592 all-time installs (skills.sh)
  • +55 installs in the week ending Jul 28, 2026 (Skillselion tracking)
  • Ranked #302 of 4,386 Backend & APIs skills by installs in the Skillselion catalog
  • Security screen: MEDIUM risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

aws-sdk-java-v2-kms capabilities & compatibility

Capabilities
aws sdk for java 2.x aws kms (key management s · 1. **set up iam permissions** grant kms:* acti · 2. **create kms client** instantiate kmsclient · 3. **create keys** use createkey() → **verify · 4. **set key policies** define key usage permi
Use cases
orchestration
From the docs

What aws-sdk-java-v2-kms says it does

Provides AWS KMS patterns using AWS SDK for Java 2.x. Covers key management, encryption/decryption, envelope encryption, digital signatures, and Spring Boot integration.
SKILL.md
1. **Set Up IAM Permissions** - Grant kms:* actions with least privilege
SKILL.md
2. **Create KMS Client** - Instantiate KmsClient with region and credentials
SKILL.md
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill aws-sdk-java-v2-kms

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1.6k
repo stars311
Security audit3 / 3 scanners passed
Last updatedJune 22, 2026
Repositorygiuseppe-trisciuoglio/developer-kit

What it does

Provides AWS Key Management Service (KMS) patterns using AWS SDK for Java 2.x. Use when creating/managing encryption keys, encrypting/decrypting data, generating data keys, digital signing, key rotati

Who is it for?

Developers working on backend & apis during build tasks.

Skip if: Tasks outside Backend & APIs scope described in SKILL.md.

When should I use this skill?

Provides AWS Key Management Service (KMS) patterns using AWS SDK for Java 2.x. Use when creating/managing encryption keys, encrypting/decrypting data, generating data keys, digital signing, key rotati

What you get

Completed backend & apis workflow aligned with SKILL.md steps.

  • KMS client integration code
  • encrypt-decrypt service methods

By the numbers

  • 1104 installs listed on skills.sh for giuseppe-trisciuoglio/developer-kit/aws-sdk-java-v2-kms

Files

SKILL.mdMarkdownGitHub ↗

AWS SDK for Java 2.x - AWS KMS (Key Management Service)

Overview

Provides AWS KMS patterns using AWS SDK for Java 2.x. Covers key management, encryption/decryption, envelope encryption, digital signatures, and Spring Boot integration.

Instructions

1. Set Up IAM Permissions - Grant kms: actions with least privilege 2. Create KMS Client - Instantiate KmsClient with region and credentials 3. Create Keys - Use createKey() → Verify key state is ENABLED before proceeding 4. Set Key Policies - Define key usage permissions → Test access before production 5. Encrypt Data - Use encrypt() for data <4KB; Verify ciphertext is not empty 6. Envelope Encryption - For larger data, use generateDataKey() → Verify data key generation succeeded 7. Digital Signatures - Create signing keys → Verify signatureValid=true after sign/verify 8. Key Rotation - Enable auto-rotation → Confirm rotation schedule is active*

When to Use

  • Creating/managing symmetric encryption keys for data protection
  • Implementing envelope encryption for large data
  • Generating data keys for local encryption with KMS-managed keys
  • Setting up digital signatures with asymmetric keys
  • Integrating encryption into Spring Boot applications

Dependencies

Maven

<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>kms</artifactId>
</dependency>

Gradle

implementation 'software.amazon.awssdk:kms:2.x.x'

Client Setup

Basic Synchronous Client

import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.kms.KmsClient;

KmsClient kmsClient = KmsClient.builder()
    .region(Region.US_EAST_1)
    .build();

Basic Asynchronous Client

import software.amazon.awssdk.services.kms.KmsAsyncClient;

KmsAsyncClient kmsAsyncClient = KmsAsyncClient.builder()
    .region(Region.US_EAST_1)
    .build();

Advanced Client Configuration

KmsClient kmsClient = KmsClient.builder()
    .region(Region.of(System.getenv("AWS_REGION")))
    .credentialsProvider(DefaultCredentialsProvider.create())
    .overrideConfiguration(c -> c.retryPolicy(RetryPolicy.builder()
        .numRetries(3)
        .build()))
    .build();

Basic Key Management

Create Encryption Key

public String createEncryptionKey(KmsClient kmsClient, String description) {
    CreateKeyRequest request = CreateKeyRequest.builder()
        .description(description)
        .keyUsage(KeyUsageType.ENCRYPT_DECRYPT)
        .build();

    CreateKeyResponse response = kmsClient.createKey(request);
    return response.keyMetadata().keyId();
}

Describe Key

public KeyMetadata getKeyMetadata(KmsClient kmsClient, String keyId) {
    DescribeKeyRequest request = DescribeKeyRequest.builder()
        .keyId(keyId)
        .build();

    return kmsClient.describeKey(request).keyMetadata();
}

Enable/Disable Key

public void toggleKeyState(KmsClient kmsClient, String keyId, boolean enable) {
    if (enable) {
        kmsClient.enableKey(EnableKeyRequest.builder().keyId(keyId).build());
    } else {
        kmsClient.disableKey(DisableKeyRequest.builder().keyId(keyId).build());
    }
}

Basic Encryption and Decryption

Encrypt Data

public String encryptData(KmsClient kmsClient, String keyId, String plaintext) {
    SdkBytes plaintextBytes = SdkBytes.fromString(plaintext, StandardCharsets.UTF_8);

    EncryptRequest request = EncryptRequest.builder()
        .keyId(keyId)
        .plaintext(plaintextBytes)
        .build();

    EncryptResponse response = kmsClient.encrypt(request);
    return Base64.getEncoder().encodeToString(
        response.ciphertextBlob().asByteArray());
}

Decrypt Data

public String decryptData(KmsClient kmsClient, String ciphertextBase64) {
    byte[] ciphertext = Base64.getDecoder().decode(ciphertextBase64);
    SdkBytes ciphertextBytes = SdkBytes.fromByteArray(ciphertext);

    DecryptRequest request = DecryptRequest.builder()
        .ciphertextBlob(ciphertextBytes)
        .build();

    DecryptResponse response = kmsClient.decrypt(request);
    return response.plaintext().asString(StandardCharsets.UTF_8);
}

Envelope Encryption Pattern

Generate and Use Data Key

public DataKeyResult encryptWithEnvelope(KmsClient kmsClient, String masterKeyId, byte[] data) {
    try {
        GenerateDataKeyRequest keyRequest = GenerateDataKeyRequest.builder()
            .keyId(masterKeyId)
            .keySpec(DataKeySpec.AES_256)
            .build();

        GenerateDataKeyResponse keyResponse = kmsClient.generateDataKey(keyRequest);

        // Validate response
        if (keyResponse.plaintext() == null || keyResponse.ciphertextBlob() == null) {
            throw new IllegalStateException("Data key generation returned null");
        }

        byte[] encryptedData = encryptWithAES(data, keyResponse.plaintext().asByteArray());

        // Clear plaintext key from memory
        Arrays.fill(keyResponse.plaintext().asByteArray(), (byte) 0);

        return new DataKeyResult(encryptedData, keyResponse.ciphertextBlob().asByteArray());

    } catch (KmsException e) {
        throw new RuntimeException("Envelope encryption failed: " + e.awsErrorDetails().errorCode(), e);
    }
}

public byte[] decryptWithEnvelope(KmsClient kmsClient, DataKeyResult encryptedEnvelope) {
    try {
        DecryptRequest keyDecryptRequest = DecryptRequest.builder()
            .ciphertextBlob(SdkBytes.fromByteArray(encryptedEnvelope.encryptedKey()))
            .build();

        DecryptResponse keyDecryptResponse = kmsClient.decrypt(keyDecryptRequest);

        // Validate response
        if (keyDecryptResponse.plaintext() == null) {
            throw new IllegalStateException("Key decryption returned null");
        }

        byte[] decryptedData = decryptWithAES(
            encryptedEnvelope.encryptedData(),
            keyDecryptResponse.plaintext().asByteArray());

        // Clear plaintext key from memory
        Arrays.fill(keyDecryptResponse.plaintext().asByteArray(), (byte) 0);

        return decryptedData;

    } catch (KmsException e) {
        throw new RuntimeException("Envelope decryption failed: " + e.awsErrorDetails().errorCode(), e);
    }
}

Digital Signatures

Create Signing Key and Sign Data

public String createAndSignData(KmsClient kmsClient, String description, String message) {
    // Create signing key
    CreateKeyRequest keyRequest = CreateKeyRequest.builder()
        .description(description)
        .keySpec(KeySpec.RSA_2048)
        .keyUsage(KeyUsageType.SIGN_VERIFY)
        .build();

    CreateKeyResponse keyResponse = kmsClient.createKey(keyRequest);
    String keyId = keyResponse.keyMetadata().keyId();

    // Sign data
    SignRequest signRequest = SignRequest.builder()
        .keyId(keyId)
        .message(SdkBytes.fromString(message, StandardCharsets.UTF_8))
        .signingAlgorithm(SigningAlgorithmSpec.RSASSA_PSS_SHA_256)
        .build();

    SignResponse signResponse = kmsClient.sign(signRequest);
    return Base64.getEncoder().encodeToString(
        signResponse.signature().asByteArray());
}

Verify Signature

public boolean verifySignature(KmsClient kmsClient,
                             String keyId,
                             String message,
                             String signatureBase64) {
    byte[] signature = Base64.getDecoder().decode(signatureBase64);

    VerifyRequest verifyRequest = VerifyRequest.builder()
        .keyId(keyId)
        .message(SdkBytes.fromString(message, StandardCharsets.UTF_8))
        .signature(SdkBytes.fromByteArray(signature))
        .signingAlgorithm(SigningAlgorithmSpec.RSASSA_PSS_SHA_256)
        .build();

    VerifyResponse verifyResponse = kmsClient.verify(verifyRequest);
    return verifyResponse.signatureValid();
}

Spring Boot Integration

Configuration Class

@Configuration
public class KmsConfiguration {

    @Bean
    public KmsClient kmsClient() {
        return KmsClient.builder()
            .region(Region.US_EAST_1)
            .build();
    }

    @Bean
    public KmsAsyncClient kmsAsyncClient() {
        return KmsAsyncClient.builder()
            .region(Region.US_EAST_1)
            .build();
    }
}

Encryption Service

@Service
@RequiredArgsConstructor
public class KmsEncryptionService {

    private final KmsClient kmsClient;

    @Value("${kms.encryption-key-id}")
    private String keyId;

    public String encrypt(String plaintext) {
        try {
            EncryptRequest request = EncryptRequest.builder()
                .keyId(keyId)
                .plaintext(SdkBytes.fromString(plaintext, StandardCharsets.UTF_8))
                .build();

            EncryptResponse response = kmsClient.encrypt(request);
            return Base64.getEncoder().encodeToString(
                response.ciphertextBlob().asByteArray());

        } catch (KmsException e) {
            throw new RuntimeException("Encryption failed", e);
        }
    }

    public String decrypt(String ciphertextBase64) {
        try {
            byte[] ciphertext = Base64.getDecoder().decode(ciphertextBase64);

            DecryptRequest request = DecryptRequest.builder()
                .ciphertextBlob(SdkBytes.fromByteArray(ciphertext))
                .build();

            DecryptResponse response = kmsClient.decrypt(request);
            return response.plaintext().asString(StandardCharsets.UTF_8);

        } catch (KmsException e) {
            throw new RuntimeException("Decryption failed", e);
        }
    }
}

Examples

Basic Encryption Example

public class BasicEncryptionExample {
    public static void main(String[] args) {
        KmsClient kmsClient = KmsClient.builder()
            .region(Region.US_EAST_1)
            .build();

        // Create key
        String keyId = createEncryptionKey(kmsClient, "Example encryption key");
        System.out.println("Created key: " + keyId);

        // Encrypt and decrypt
        String plaintext = "Hello, World!";
        String encrypted = encryptData(kmsClient, keyId, plaintext);
        String decrypted = decryptData(kmsClient, encrypted);

        System.out.println("Original: " + plaintext);
        System.out.println("Decrypted: " + decrypted);
    }
}

Envelope Encryption Example

public class EnvelopeEncryptionExample {
    public static void main(String[] args) {
        KmsClient kmsClient = KmsClient.builder()
            .region(Region.US_EAST_1)
            .build();

        String masterKeyId = "alias/your-master-key";
        String largeData = "This is a large amount of data that needs encryption...";
        byte[] data = largeData.getBytes(StandardCharsets.UTF_8);

        // Encrypt using envelope pattern
        DataKeyResult encryptedEnvelope = encryptWithEnvelope(
            kmsClient, masterKeyId, data);

        // Decrypt
        byte[] decryptedData = decryptWithEnvelope(
            kmsClient, encryptedEnvelope);

        String result = new String(decryptedData, StandardCharsets.UTF_8);
        System.out.println("Decrypted: " + result);
    }
}

Best Practices

Security

  • Always use envelope encryption for large data - Encrypt data locally and only encrypt the data key with KMS
  • Use encryption context - Add contextual information to track and audit usage
  • Never log sensitive data - Avoid logging plaintext or encryption keys
  • Implement proper key lifecycle - Enable automatic rotation and set deletion policies
  • Use separate keys for different purposes - Don't reuse keys across multiple applications

Performance

  • Cache encrypted data keys - Reduce KMS API calls by caching data keys
  • Use async operations - Leverage async clients for non-blocking I/O
  • Reuse client instances - Don't create new clients for each operation
  • Implement connection pooling - Configure proper connection pooling settings

Error Handling

  • Implement retry logic - Handle throttling exceptions with exponential backoff
  • Check key states - Verify key is enabled before performing operations
  • Use circuit breakers - Prevent cascading failures during KMS outages
  • Log errors comprehensively - Include KMS error codes and context

References

For detailed implementation patterns, advanced techniques, and comprehensive examples:

  • @references/technical-guide.md - Complete technical implementation patterns
  • @references/spring-boot-integration.md - Spring Boot integration patterns
  • @references/testing.md - Testing strategies and examples
  • @references/best-practices.md - Security and operational best practices

Related Skills

  • @aws-sdk-java-v2-core - Core AWS SDK patterns and configuration
  • @aws-sdk-java-v2-dynamodb - DynamoDB integration patterns
  • @aws-sdk-java-v2-secrets-manager - Secrets management patterns
  • @spring-boot-dependency-injection - Spring dependency injection patterns

External References

Constraints and Warnings

  • Data Size Limit: Direct encryption limited to 4KB; use envelope encryption for larger data
  • Key Usage Limits: KMS has quotas on API calls per second
  • Key Material: Imported key material cannot be managed by AWS for rotation
  • Key Deletion: Key deletion requires 7-30 day waiting period
  • Regional Boundaries: KMS keys cannot be used across regions
  • Cost Considerations: KMS charges per API call and for key storage
  • Asymmetric Keys: Not all regions support asymmetric key types
  • Key Policies: Changes to key policies require careful IAM review
  • Envelope Encryption: Proper implementation required for data key security
  • Logging: Enable CloudTrail to audit all KMS API usage

Related skills

Forks & variants (1)

Aws Sdk Java V2 Kms has 1 known copy in the catalog totaling 20 installs. They canonicalize to this original listing.

How it compares

Use aws-sdk-java-v2-kms for Java-specific SDK v2 KMS snippets; reach for a secrets-manager skill when you only need credential storage without encryption APIs.

FAQ

What does aws-sdk-java-v2-kms do?

Provides AWS Key Management Service (KMS) patterns using AWS SDK for Java 2.x. Use when creating/managing encryption keys, encrypting/decrypting data, generating data keys, digital signing, key rotati

When should I use aws-sdk-java-v2-kms?

During build backend work for backend & apis.

Is aws-sdk-java-v2-kms safe to install?

Review the Security Audits panel on this listing before production use.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.