Decouple common-aws from environment and add subpath exports#26
Merged
Decouple common-aws from environment and add subpath exports#26
Conversation
These hash utilities have no server-side dependencies beyond crypto, so they belong in the lightweight common package. Allow crypto in common eslint config. Re-exports from common-server for backwards compatibility.
Make tableName required instead of deriving it from the environment at runtime. Remove dynamoTableName() and assertTableNameValid() helpers that coupled the library to a specific naming convention. Decouple SQS consumer from implicit PartitionedKeyValueTable and environment checks by accepting proxyProvider via opts.
Move createTable logic into a standalone DynamoUtil class so table management is not tied to the Docker test helper. Add removeTable for cleanup. DynamoDocker delegates to DynamoUtil for backwards compat.
Add exports field with 12 subpath entries so consumers can import only the modules they need without pulling in the full dependency tree. Move AWS SDK, common-server, aws-lambda, and datadog-lambda-js to optional peerDependencies (with devDependencies for local build/test). Bump AWS SDK peer deps to ^3.1002.0. Create sns/index.ts barrel for consistency. Version bump to 3.0.0 (breaking: peer dep migration).
Update common-aws README with subpath export table and per-module peer dependency requirements. Bump all workspace packages to 3.0.0 for the breaking change.
Prevents the SDK from walking the default credential provider chain (which tries SSO, instance metadata, etc.) when connecting to a local DynamoDB container that doesn't check credentials.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consumers of
common-awswere forced to install every dependency (common-server, aws-lambda, datadog-lambda-js, all AWS SDK clients) even when they only needed a single module likePartitionedKeyValueTable. This PR breaks that coupling so each subpath carries only the deps it actually uses.Summary
exportsfield with 12 subpath entries (./dynamo/keys,./sqs,./s3, etc.) so consumers import only what they needcommon-server,aws-lambda, anddatadog-lambda-jsfrom direct dependencies to optional peer dependencies (with dev dependencies for local build/test)^3.835.0to^3.1002.0dynamoTableName()andassertTableNameValid()— table names are now required, not derived from the runtime environmentPartitionedKeyValueTableand environment checks; acceptproxyProvidervia optsDynamoUtilclass fromDynamoDockerwithcreateTableandremoveTableso table management isn't tied to Dockermd5/consistentMd5fromcommon-servertocommon(re-exported from common-server for compat)sns/index.tsbarrel for subpath export consistencyUsage
Relevant Gif