Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with AWS SDK JS v3 KMS client and X-Ray SDK captureAWSv3Client #1445

Open
aripalo opened this issue Aug 13, 2024 · 1 comment

Comments

@aripalo
Copy link

aripalo commented Aug 13, 2024

Problem:

Apparently this library should support SDK JS v3 KMS client (see #916), but it seems that constructing one's own client provider with v3 KMS client (that is captured with X-Ray) is not possible? Or what am I missing?

This relates to issue #191 which suggest capturing v2 client like so:

const AWSXRay = require('aws-xray-sdk')
const { getKmsClient, cacheClients } = require('@aws-crypto/client-node')
const clientProvider = cacheClients(region => AWSXRay.captureAWSClient(getKmsClient(region)))

… but one can't utilize captureAWSv3Client as it seems that getKmsClient is only returning v2 SDK (API compatible) client (and v2 has been deprecated):

import { captureAWSv3Client } from "aws-xray-sdk-core";

const clientProvider = cacheClients((region) => captureAWSv3Client(getKmsClient(region)));

Solution:

Unfortunately I don't yet understand the inner architecture of the Encryption SDK, but on a high-level, it should be possible to just use SDK v3 modules (with X-Ray capture/tracing) as v2 has been deprecated.

If this is already supported, it should be somehow covered by the docs or at least by the examples.

@clementallen
Copy link

@aripalo I was able to add X-Ray tracing for a Lambda use case without issues:

const clientProvider = cacheClients((region) => tracer.captureAWSv3Client(getKmsClient(region)));

This was using the Lambda Powertools library, docs here: https://docs.powertools.aws.dev/lambda/typescript/latest/core/tracer/#patching-aws-sdk-clients

I can't imagine the implementation under the hood of Powertools is much different to aws-xray-sdk-core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants