Segment Functions AWS SDK v3 Upgrade
AWS SDK v3 upgrade
Amazon Web Services (AWS) ended support for the AWS SDK for JavaScript v2 on September 8, 2025. Segment added AWS SDK v3 to the Functions runtime, available as AWSv3.
Twilio Segment keeps the libraries available to Functions current with industry standards. AWS moved the AWS SDK for JavaScript v2 into maintenance mode in September 2024 and ended support on September 8, 2025. AWS stopped providing new features, bug fixes, or security patches to SDK v2. You can use AWS SDK v3 in the Functions runtime alongside v2.
If your function uses AWS:
- Update your code to use
AWSv3instead ofAWS. - Test and redeploy your function.
Unlike the Node.js runtime upgrade, this upgrade requires code changes. Redeploying your function alone doesn't migrate it to AWS SDK v3.
Your deployed functions continue to run on AWS SDK v2.
- If you create a function that uses AWS, use
AWSv3. - Until Twilio removes AWS SDK v2 from the Functions runtime, existing functions that use
AWScontinue to work. - After Twilio removes
AWS, functions that use it fail. Twilio will provide advance notice.
Migrate as soon as possible
Regardless of any other planned changes to your function, Twilio Segment recommends migrating to AWS SDK v3 as soon as possible.
Test your functions before deploying
AWS SDK v3 changes how Twilio Segment returns some responses and errors. Before you deploy your updated function, test it with sample events and confirm it behaves as expected.
Access AWS services through AWSv3.<Service>.
Read an S3 object example
1const s3 = new AWS.S3()2const data = await s3.getObject({ Bucket, Key }).promise()
Assume, then use a role example
1const { Credentials } = await new AWS.STS().assumeRole(params).promise()2AWS.config.update({ credentials: new AWS.Credentials(3Credentials.AccessKeyId, Credentials.SecretAccessKey, Credentials.SessionToken) })4const s3 = new AWS.S3()
| What | v2 | v3 |
|---|---|---|
| Create a client | new AWS.S3() | new AWSv3.S3.S3Client({ region }) |
| Make a call | s3.getObject(params).promise() | s3.send(new GetObjectCommand(params)) |
| Callbacks | s3.getObject(params, (err, data) => …) | Use await with .send() |
| Region | Inherited from AWS.config | Required on every client: { region: '…' } |
| Credentials | AWS.config.update({ credentials }) | Pass per client: credentials: { accessKeyId, secretAccessKey, sessionToken } |
| Config object | new AWS.Config({ … }) | No v3 equivalent — pass { region, credentials } to each client |
| Read an S3 object body | data.Body.toString() | await data.Body.transformToString() |
| Read other binary data | value.toString('utf8') | Buffer.from(value).toString('utf8') |
| Check an error type | err.code === 'NoSuchKey' | err.name === 'NoSuchKey' |
| Check an error status | err.statusCode | err.$metadata.httpStatusCode |
| What | v2 | v3 |
|---|---|---|
| Upload to S3 | s3.upload(params).promise() | new AWSv3.S3Upload.Upload({ client, params }).done() |
| DynamoDB DocumentClient | new AWS.DynamoDB.DocumentClient() | AWSv3.DynamoDBDocument.DynamoDBDocumentClient.from(client) |
| Wait for a resource | s3.waitFor('objectExists', params).promise() | await AWSv3.S3.waitUntilObjectExists({ client }, params) |
| Paginate results | .eachPage(…) | for await (const page of AWSv3.S3.paginateListObjectsV2({ client }, params)) |
| Retry and timeout options | maxRetries, httpOptions | maxAttempts (retries + 1), requestHandler |
| S3 path style | s3ForcePathStyle: true | forcePathStyle: true |
| Custom endpoint | new AWS.Endpoint(url) | endpoint: '' |
| EventBridge | new AWS.CloudWatchEvents() | AWSv3.EventBridge |
apiVersion option | apiVersion: '2012-08-10' | Ignored in v3; you can remove it |
Import the SDK
To import the AWS SDK, use the AWSv3 global. You can't import it with require().
In the Segment app, update your code in the Functions editor, then send a sample event.
- Open your function.
- Update your code for
AWSv3. - To send a sample event, use the Test tab. Confirm the function behaves as expected.
- Click Save & Deploy. This deploys the updated function.
With the Public API, update your function's code then deploy an updated version. To find the endpoints that apply to your function type, see the Public API reference.
Are you using an AWS feature not covered here? [Contact Segment Support][].