auto-generated-aws-client-singleton-pattern

Manage AWS SDK clients as lazy, reusable singletons across Lambda invocations.

Updated Aug 17, 2025
One-click install
npx skills add https://github.com/planetaryescape/ai-digest --skill auto-generated-aws-client-singleton-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auto-generated-aws-client-singleton-pattern
Source: https://github.com/planetaryescape/ai-digest/tree/main/.claude/skills/auto-generated-aws-client-singleton-pattern
Command: npx skills add https://github.com/planetaryescape/ai-digest --skill auto-generated-aws-client-singleton-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Manage AWS SDK clients across environments by providing lazy, reusable singletons to avoid per-invocation client creation and simplify credential handling.

Core Features & Use Cases

  • Lazy singleton client creation shared across Lambda invocations
  • Conditional credentials depending on frontend vs backend
  • DynamoDBDocumentClient wrapper for automatic JSON marshalling
  • Inline client initialization when scoped to a class or function
  • Token storage pattern for testability and reuse
  • Clear guidance on region configuration and client reuse

Quick Start

Import the AWS client helper and call the provided getter to reuse a lazily-initialized client across Lambda invocations.

Frequently Asked Questions about auto-generated-aws-client-singleton-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reuse AWS SDK clients across Lambda invocations without creating a new instance each time?

You can reuse AWS SDK clients across Lambda invocations by implementing lazy singleton patterns that initialize the client once and persist it in the execution environment, avoiding per-invocation client creation overhead.

What is the best way to handle AWS credentials conditionally for frontend versus backend environments?

Handling AWS credentials conditionally involves applying different credential resolution strategies depending on whether the context is frontend or backend, ensuring safe and appropriate access management for each environment scope.

How do I set up a DynamoDBDocumentClient wrapper for automatic JSON marshalling in Lambda?

Setting up a DynamoDBDocumentClient wrapper requires wrapping the standard DynamoDB client to automatically handle JSON marshalling, simplifying data operations by seamlessly converting JavaScript objects to DynamoDB attribute formats.

Why does my AWS SDK client initialization fail when the region is not set in environment variables?

AWS SDK client initialization fails without a region because the lazy singleton pattern explicitly enforces loading the region from environment variables, ensuring consistent configuration and preventing ambiguous deployment targets.

Can I use inline client initialization for AWS SDK singletons scoped to a specific class or function?

Yes, you can use inline client initialization to scope AWS SDK singletons to a specific class or function, which provides localized client access while maintaining the testability and reuse benefits of the singleton pattern.

Does the AWS client singleton pattern support token storage for testability?

Yes, the AWS client singleton pattern supports token storage for testability by allowing you to inject and manage mock tokens, ensuring that client instances can be safely reused and validated across different test scenarios.