How can I use AWS SDK Environment Variables on Vercel?

Vercel has certain reserved Environment Variable names that cannot be used for your deployments. For example, AWS_REGION. You will need to choose a different Environment Variable name when using the AWS SDK.

Connecting to the AWS SDK

Once you've selected an Environment Variable name that is not AWS_REGION, you can connect to the AWS SDK as follows:

import aws from 'aws-sdk' // Ensure you add these values as Environment Variables // aws.config.update({ accessKeyId: process.env.ACCESS_KEY, secretAccessKey: process.env.SECRET_KEY, region: process.env.REGION, signatureVersion: 'v4', }) // You can now create/retrieve objects from your bucket const s3 = new aws.S3()

Example code to connect to the AWS SDK.

Updated June 15th 2022