Search code examples
aws-sdkaws-sdk-nodejs

converting types from aws sdk v2 to v3 (typescript)


I am migrating a typescript codebase from aws sdk v2 to v3. In my code I have used several types from aws sdk v2 as follows:

import * as AWS from 'aws-sdk';
export async function uploadFn(
  s3: AWS.S3,
  ........
)

However, for types such as AWS.S3 (and others) I can't find the equivalent type I should use in v3, and I've only been able to find the client/command equivalents of the functions I would normally call with an S3 object in aws sdk v2. Does anyone know if an equivalent type of AWS.S3 (as in the code above) exists in v3, or should I change to type any?


Solution

  • There is no v3 equivalent of the v2 AWS object. The v3 SDK is modular:

    The SDK is now split up across multiple packages. The 2.x version of the SDK contained support for every service.

    The S3 client and commands, for instance, are packaged in @aws-sdk/client-s3:

    import { S3Client, ListBucketsCommand } from '@aws-sdk/client-s3';
    

    The v3 packages have first-class Typescript support.