Skip to contentSkip to navigationSkip to topbar
Page tools
Useful for sharing or LLM
Accelerate development with AI

On this page
Looking for more inspiration?Visit the

Segment Functions AWS SDK v3 Upgrade


(information)

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(link takes you to an external page) 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.


What do I need to do?

what-do-i-need-to-do page anchor

If your function uses AWS:

  1. Update your code to use AWSv3 instead of AWS.
  2. 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.


What happens if I take no action?

what-happens-if-i-take-no-action page anchor

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 AWS continue to work.
  • After Twilio removes AWS, functions that use it fail. Twilio will provide advance notice.
(information)

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.


How do I upgrade to AWS SDK v3?

how-do-i-upgrade-to-aws-sdk-v3 page anchor
(warning)

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.

Update your function code

update-your-function-code page anchor

Access AWS services through AWSv3.<Service>.

(information)

Read an S3 object example

v2v3
1
const s3 = new AWS.S3()
2
const data = await s3.getObject({ Bucket, Key }).promise()
(information)

Assume, then use a role example

v2v3
1
const { Credentials } = await new AWS.STS().assumeRole(params).promise()
2
AWS.config.update({ credentials: new AWS.Credentials(
3
Credentials.AccessKeyId, Credentials.SecretAccessKey, Credentials.SessionToken) })
4
const s3 = new AWS.S3()

Changes that apply to most functions

changes-that-apply-to-most-functions page anchor
Whatv2v3
Create a clientnew AWS.S3()new AWSv3.S3.S3Client({ region })
Make a calls3.getObject(params).promise()s3.send(new GetObjectCommand(params))
Callbackss3.getObject(params, (err, data) => …)Use await with .send()
RegionInherited from AWS.configRequired on every client: { region: '…' }
CredentialsAWS.config.update({ credentials })Pass per client: credentials: { accessKeyId, secretAccessKey, sessionToken }
Config objectnew AWS.Config({ … })No v3 equivalent — pass { region, credentials } to each client
Read an S3 object bodydata.Body.toString()await data.Body.transformToString()
Read other binary datavalue.toString('utf8')Buffer.from(value).toString('utf8')
Check an error typeerr.code === 'NoSuchKey'err.name === 'NoSuchKey'
Check an error statuserr.statusCodeerr.$metadata.httpStatusCode

Changes that apply as needed

changes-that-apply-as-needed page anchor
Whatv2v3
Upload to S3s3.upload(params).promise()new AWSv3.S3Upload.Upload({ client, params }).done()
DynamoDB DocumentClientnew AWS.DynamoDB.DocumentClient()AWSv3.DynamoDBDocument.DynamoDBDocumentClient.from(client)
Wait for a resources3.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 optionsmaxRetries, httpOptionsmaxAttempts (retries + 1), requestHandler
S3 path styles3ForcePathStyle: trueforcePathStyle: true
Custom endpointnew AWS.Endpoint(url)endpoint: ''
EventBridgenew AWS.CloudWatchEvents()AWSv3.EventBridge
apiVersion optionapiVersion: '2012-08-10'Ignored in v3; you can remove it
(information)

Import the SDK

To import the AWS SDK, use the AWSv3 global. You can't import it with require().

Test and deploy your function

test-and-deploy-your-function page anchor

In the Segment app, update your code in the Functions editor, then send a sample event.

  1. Open your function.
  2. Update your code for AWSv3.
  3. To send a sample event, use the Test tab. Confirm the function behaves as expected.
  4. 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(link takes you to an external page).

Are you using an AWS feature not covered here? [Contact Segment Support][].

Contact Segment Support(link takes you to an external page)