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

Upgrading to AWS SDK V3 #84

Open
ChristopheBougere opened this issue Mar 29, 2021 · 1 comment
Open

Upgrading to AWS SDK V3 #84

ChristopheBougere opened this issue Mar 29, 2021 · 1 comment

Comments

@ChristopheBougere
Copy link

The V3 of the SDK is now generally available (see blog post).

The AWS SDK for JavaScript v3 is a rewrite of v2 with some great new features. As with version 2, it enables you to easily work with Amazon Web Services, but has a modular architecture with a separate package for each service. It also includes many frequently requested features, such as a first-class TypeScript support and a new middleware stack. For more details, visit blog post on general availability of Modular AWS SDK for JavaScript.

It would be great to be able to use it in this package.

In order to keep the v2 compatibility, we could provide the client during initialization instead of requiring it in this package:

import { RDSDataClient } from '@aws-sdk/client-rds-data';
const data = require('data-api-client')({
  client: new RDSDataClient({
    region: process.env.AWS_REGION,
  }),
  secretArn: 'arn:aws:secretsmanager:us-east-1:XXXXXXXXXXXX:secret:mySecret',
  resourceArn: 'arn:aws:rds:us-east-1:XXXXXXXXXXXX:cluster:my-cluster-name',
  database: 'myDatabase' // default database
});

Instead of:

const data = require('data-api-client')({
  secretArn: 'arn:aws:secretsmanager:us-east-1:XXXXXXXXXXXX:secret:mySecret',
  resourceArn: 'arn:aws:rds:us-east-1:XXXXXXXXXXXX:cluster:my-cluster-name',
  database: 'myDatabase' // default database
})
@HaaLeo
Copy link

HaaLeo commented May 31, 2022

I found this issue because I wanted to inject custom credentials to the data api client which I use via the typeorm-aurora-data-api-driver. In my project I already migrated to the aws-sdk v3.
However, it seems that @aws-sdk/credential-providers is somewhat compatible with aws-sdk v2.

The following works for me:

// Import from AWS SDK v3
import { fromIni } from '@aws-sdk/credential-providers';

const { AWS_PROFILE: profile } = process.env;

const options = {
    // ... other options

    // Passed to the AWS SDK V2 RDSDataClient
    serviceConfiguration: {
        credentialProvider: fromIni({ profile }) // this works ✅
    }
}

Maybe that helps somebody with the same issue :). However, I am looking forward when this package is migrated to the AWS SDK v3 ✨.

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