Amplify Toolbox
    Preparing search index...
    type AmplifyStorageProps = {
        isDefault?: boolean;
        keepOnDelete?: boolean;
        name: string;
        outputStorageStrategy?: BackendOutputStorageStrategy<StorageOutput>;
        triggers?: Partial<
            Record<
                AmplifyStorageTriggerEvent,
                ConstructFactory<ResourceProvider<FunctionResources>>,
            >,
        >;
        versioned?: boolean;
    }
    Index

    Properties

    isDefault?: boolean

    Whether this storage resource is the default storage resource for the backend. required and relevant only if there are multiple storage resources defined.

    false.
    
    keepOnDelete?: boolean

    Whether to keep the S3 bucket when the stack is deleted.

    • true — The bucket and its objects are preserved when the stack is removed.
    • false — The bucket and all objects are deleted when the stack is removed.

    Sandbox deployments (via npx ampx sandbox) always delete the bucket regardless of this setting.

    export const storage = defineStorage({
    name: 'productionData',
    keepOnDelete: true,
    });
    false
    
    name: string

    Friendly name that will be used to derive the S3 Bucket name

    triggers?: Partial<
        Record<
            AmplifyStorageTriggerEvent,
            ConstructFactory<ResourceProvider<FunctionResources>>,
        >,
    >

    S3 event trigger configuration

    import { triggerHandler } from '../functions/trigger-handler/resource.ts'

    export const storage = defineStorage({
    triggers: {
    onUpload: triggerHandler
    }
    })
    versioned?: boolean

    Whether to enable S3 object versioning on the bucket.