Boto3 to AWS SDK v2 Converter: Python to TypeScript

Convert Python boto3 code to TypeScript for the aws-sdk v2 package, for projects that are still pinned to v2. AWS SDK for JavaScript v2 reached end-of-support on September 8, 2025, so for anything new, use the SDK v3 version.

Your codePython (boto3)
Drop the file to load it
Tab indents · Esc, Tab exits
ResultTypeScript (SDK v2)
Your TypeScript (SDK v2) will appear hereClick Convert to TypeScript or press Ctrl Enter
converted.ts
Don't paste secrets

How to convert boto3 code to AWS SDK v2

To convert boto3 code to AWS SDK for JavaScript v2, paste the Python above and press Convert to TypeScript. Each boto3 client becomes an AWS service object such as new AWS.SQS(), snake_case methods become camelCase, and every call ends in .promise() and is awaited. Then test it inside the v2 project it's meant for.

  1. Add your boto3 codePaste Python into the Python (boto3) editor, open a .py file up to 500 KB, or drop one onto the editor. Sample loads a small job that forwards SQS messages to an SNS topic.
  2. Check for secretsBefore anything leaves the page, it looks for AWS keys, private keys and common API tokens. Swap any it finds for placeholders; the v2 SDK reads credentials from the same places boto3 does.
  3. Convert to TypeScriptClick Convert to TypeScript or press Ctrl + Enter, and watch the output stream in. Stop it early if you pasted the wrong file. The limit is 60,000 characters per conversion.
  4. Review against the originalMatch each boto3 call to its v2 method, and look closely at fallback values and pagination loops. Resolve any TODO: comments, then copy the result or download converted.ts.
  5. Drop it into the v2 projectMake sure the project depends on aws-sdk v2 (npm install aws-sdk@2), compile with tsc and run your tests. On the Node.js 18 and later Lambda runtimes, bundle aws-sdk with the function.
Four-step boto3 to AWS SDK v2 workflow: paste a boto3 script, secret check in the browser, TypeScript using .promise() calls, then bundle aws-sdk and test
The conversion flow, ending with bundling aws-sdk v2 alongside your code.

When converting boto3 to SDK v2 still makes sense

Most of the time it doesn't. v2 no longer gets updates or security fixes, and new code written against it is code you'll migrate again. But some teams can't change SDKs mid-project: a service may share v2 wrappers, helpers and mocks across dozens of files, or a release freeze may rule out a dependency change. If a Python job has to move into that codebase now, matching its SDK keeps the change small.

This converter writes TypeScript that sits comfortably next to existing aws-sdk code, with AWS.* service objects, v2 request types and .promise() calls. When the project is ready to upgrade, the AWS SDK v2 to v3 converter can take the same file forward.

Starting something new? Use the boto3 to SDK v3 converter. v3 is included in the current Lambda Node.js runtimes and won't need a second migration.

Decision diagram: use the boto3 to SDK v2 converter only if the target project is locked to aws-sdk v2, otherwise use the boto3 to SDK v3 converter; v2 reached end-of-support on September 8, 2025
Pick v2 only when the destination project can't change SDKs yet.

How boto3 maps to AWS SDK for JavaScript v2

In v2, each boto3 call becomes a method on a service client followed by .promise(). sqs.receive_message(QueueUrl=url, MaxNumberOfMessages=10) becomes await sqs.receiveMessage({ QueueUrl: url, MaxNumberOfMessages: 10 }).promise(). Method names change to camelCase, while parameter names stay the same because both SDKs follow the AWS API.

boto3's DynamoDB Table resource maps to AWS.DynamoDB.DocumentClient, which also accepts native values. Paginators become loops that pass NextToken or ContinuationToken into the next request, and except ClientError becomes a catch that checks err.code.

Credentials and region resolve much as they do in boto3: environment variables, the shared ~/.aws files, then the IAM role of the machine or function. The AWS SDK for JavaScript v2 developer guide still documents the v2 APIs.

AWS SDK for JavaScript v2 reached end-of-support on September 8, 2025 and receives no more updates. The Node.js 18 and later Lambda runtimes don't include it, so v2 code must bundle aws-sdk itself.

Mapping from boto3 to aws-sdk v2: boto3.client('sqs') to new AWS.SQS(), receive_message to receiveMessage, calls ending in .promise(), Table to DocumentClient, paginators to NextToken loops, error codes to err.code
How common boto3 calls look once they're written for aws-sdk v2.

boto3 vs AWS SDK v2: quick reference

How the everyday boto3 patterns look in aws-sdk v2. Parameters keep their AWS names; method names and error handling change.

boto3 compared with AWS SDK for JavaScript v2, by task
Taskboto3 (Python)aws-sdk v2 (TypeScript)
Installpip install boto3npm install aws-sdk@2
Create a clientboto3.client("sqs")new AWS.SQS()
Set the regionboto3.client("sqs", region_name="eu-west-1")new AWS.SQS({ region: "eu-west-1" })
Named profileboto3.Session(profile_name="dev")new AWS.SharedIniFileCredentials({ profile: "dev" })
Call an APIsqs.receive_message(QueueUrl=url)await sqs.receiveMessage({ QueueUrl: url }).promise()
DynamoDB itemsboto3.resource("dynamodb").Table("orders")new AWS.DynamoDB.DocumentClient() with TableName on each call
Read an S3 objectobj["Body"].read()obj.Body is already a Buffer in Node.js
Paginations3.get_paginator("list_objects_v2")A loop that passes NextContinuationToken back in, or .eachPage()
Waiterss3.get_waiter("bucket_exists").wait(Bucket=b)await s3.waitFor("bucketExists", { Bucket: b }).promise()
Presigned URLss3.generate_presigned_url("get_object", Params=p, ExpiresIn=900)await s3.getSignedUrlPromise("getObject", { ...p, Expires: 900 })
Error codeerr.response["Error"]["Code"]err.code
HTTP statuserr.response["ResponseMetadata"]["HTTPStatusCode"]err.statusCode

What the converter handles

  • Service objects and camelCase methodsboto3.client("sqs") becomes new AWS.SQS() and receive_message becomes receiveMessage, with the parameters unchanged.
  • Promises instead of callbacksCalls use .promise() with await, so the TypeScript reads top to bottom like the Python did, instead of nesting v2 callbacks.
  • Fits existing v2 codeOutput uses the AWS namespace and the type definitions bundled with aws-sdk, the style most v2 codebases already follow.
  • DynamoDB tables mappedboto3 Table resources become AWS.DynamoDB.DocumentClient, which takes plain values instead of typed attribute maps.
  • Gaps flagged with TODOAnything without a clean v2 equivalent gets the closest version plus a TODO: comment saying what to verify.
  • Secret check before sendingKeys and tokens in your Python are caught in the browser, before the code goes anywhere.
  • Copy or downloadCopy the TypeScript, or download it as converted.ts. Wrap long lines to read them without scrolling.

Examples: boto3 code converted for SDK v2

Three boto3 patterns and the aws-sdk v2 TypeScript they should become. Choose Try this example to load the Python into the converter. Your output may be formatted differently, or use another import style.

Look up a DynamoDB item

The table name moves from the resource into each request, and .get() returns a request that .promise() turns into something you can await.

boto3
import boto3

table = boto3.resource("dynamodb").Table("customers")


def get_customer(customer_id: str):
    response = table.get_item(Key={"id": customer_id})
    return response.get("Item")
aws-sdk v2
import * as AWS from "aws-sdk";

const docClient = new AWS.DynamoDB.DocumentClient();

export async function getCustomer(customerId: string) {
  const response = await docClient
    .get({ TableName: "customers", Key: { id: customerId } })
    .promise();
  return response.Item;
}

List every key in a bucket

v2 has no paginator objects like boto3's, so the loop passes NextContinuationToken back as ContinuationToken until S3 stops returning one.

boto3
import boto3

s3 = boto3.client("s3")


def list_keys(bucket: str) -> list:
    keys = []
    paginator = s3.get_paginator("list_objects_v2")
    for page in paginator.paginate(Bucket=bucket):
        keys.extend(obj["Key"] for obj in page.get("Contents", []))
    return keys
aws-sdk v2
import * as AWS from "aws-sdk";

const s3 = new AWS.S3();

export async function listKeys(bucket: string): Promise<string[]> {
  const keys: string[] = [];
  let token: string | undefined;
  do {
    const page = await s3
      .listObjectsV2({ Bucket: bucket, ContinuationToken: token })
      .promise();
    for (const obj of page.Contents ?? []) {
      if (obj.Key) keys.push(obj.Key);
    }
    token = page.NextContinuationToken;
  } while (token);
  return keys;
}

Fall back when a parameter is missing

err.code replaces the nested error dictionary, and raise becomes throw err. default is a reserved word in TypeScript, so the parameter needs a new name.

boto3
import boto3
from botocore.exceptions import ClientError

ssm = boto3.client("ssm")


def get_setting(name: str, default: str) -> str:
    try:
        return ssm.get_parameter(Name=name)["Parameter"]["Value"]
    except ClientError as err:
        if err.response["Error"]["Code"] == "ParameterNotFound":
            return default
        raise
aws-sdk v2
import * as AWS from "aws-sdk";

const ssm = new AWS.SSM();

export async function getSetting(name: string, fallback: string): Promise<string> {
  try {
    const result = await ssm.getParameter({ Name: name }).promise();
    return result.Parameter!.Value!;
  } catch (err) {
    if ((err as AWS.AWSError).code === "ParameterNotFound") {
      return fallback;
    }
    throw err;
  }
}

Tips for better results

  • Confirm it's really v2 you need. If the target project doesn't depend on aws-sdk yet, use the v3 converter instead.
  • Match the project's import style. Swap import * as AWS for whatever the codebase already uses, such as import AWS = require("aws-sdk") or per-service imports like aws-sdk/clients/sqs.
  • Test pagination with real volume. Run each loop against more than one page of results to confirm it collects everything and then stops.
  • Keep credentials out of the code. Remove hard-coded keys; v2 reads environment variables, shared config files and IAM roles, just like boto3.
  • Log the file for your v3 migration. Every v2 file you add is one more to upgrade, so note it where you track that work.

Common mistakes with boto3 to SDK v2 ports

  • Dropping .promise(). Without it, await hands back an AWS.Request object instead of the response, and nothing is sent.
  • Hiding missing values behind defaults. Output such as msg.ReceiptHandle ?? "" satisfies the compiler but sends an empty value to AWS when the field is missing. Decide whether that case should throw instead.
  • Assuming Lambda includes v2. The Node.js 18 and later runtimes only ship v3, so a v2 function fails with Cannot find module 'aws-sdk' unless you bundle it.
  • Forgetting the table name. boto3's Table resource carries its name; every DocumentClient call needs TableName in its params.
  • Mixing SDK versions in one module. Don't import @aws-sdk/* clients next to aws-sdk unless you're deliberately migrating. Clients, errors and test mocks differ between the two.

Frequently asked questions

How do I convert boto3 code to AWS SDK v2?

Paste the Python into the converter above and press Convert to TypeScript. boto3 clients become AWS service objects, methods move to camelCase, and each call ends with .promise(). Add aws-sdk v2 to the project, compile and run your tests.

Should I convert to SDK v2 or v3?

Convert to v3 unless the project must stay on v2 for now. v2 reached end-of-support on September 8, 2025, so new v2 code adds to a migration you'll need later.

Is the output TypeScript or JavaScript?

TypeScript. The aws-sdk v2 package includes its own type definitions. If you need JavaScript, compile it with tsc or remove the type annotations. The SDK calls don't change.

How are boto3 resources converted?

DynamoDB tables map to the v2 DocumentClient. Other resource calls, like iterating bucket.objects.all(), become the equivalent client calls with a pagination loop.

Will the converted code run on AWS Lambda?

Yes, if you bundle the SDK. The Node.js 18 and later runtimes don't include aws-sdk v2, so add it to your deployment package or a layer. The older runtimes that did include it are deprecated.

Is my code stored?

No. Your Python is sent to an AI model hosted on NVIDIA's API only to produce the conversion, and ChatWithCloud doesn't store or log it. The latest draft stays in your browser. For the full picture, see whether it's safe to paste AWS code into an AI converter.

Is the converter free?

Yes. Each conversion takes up to 60,000 characters. Anonymous use allows 6 conversions a minute and 60 a day; a free account raises that to 12 a minute and 200 a day. The guide to ChatWithCloud free converter limits shows how far they stretch for a real migration.

Related tools and next steps