import { Sandbox } from '@vercel/sandbox' ;
const sandbox = await Sandbox . create ( ) ;
// Install Mountpoint for Amazon S3 (official release) and its FUSE dependency.
await sandbox . runCommand ( {
sudo : true ,
cmd : 'dnf' ,
args : [
'install' ,
'-y' ,
'fuse' ,
'https://s3.amazonaws.com/mountpoint-s3-release/latest/x86_64/mount-s3.rpm' ,
] ,
} ) ;
const MOUNT_DIR = '/mnt/s3'
await sandbox . runCommand ( {
sudo : true , cmd : 'mkdir' , args : [ '-p' , MOUNT_DIR ]
} ) ;
// Pass aws credentials only to the mount-s3 command.
// Note: this does expose the credentials permanently in the sandbox!
// Use a restricted role only
await sandbox . runCommand ( {
sudo : true ,
cmd : 'mount-s3' ,
args : [
process . env . S3_BUCKET_NAME ,
MOUNT_DIR ,
'--allow-other' ,
] ,
env : {
AWS_ACCESS_KEY_ID : process . env . AWS_ACCESS_KEY_ID ,
AWS_SECRET_ACCESS_KEY : process . env . AWS_SECRET_ACCESS_KEY ,
AWS_SESSION_TOKEN : process . env . AWS_SESSION_TOKEN ,
AWS_REGION : process . env .…