anomalyco/sst · error
failed to delete S3 bucket %s: %w
Error message
failed to delete S3 bucket %s: %w
What it means
While migrating from the old bootstrap, SST empties the legacy asset bucket and deletes it. If `s3:DeleteBucket` fails for any reason other than `NoSuchBucket`, this error wraps the AWS failure. Deletion typically fails when the bucket still contains objects (including versioned ones) or permissions are missing.
Source
Thrown at pkg/project/provider/aws.go:457
Delete: &s3types.Delete{Objects: objectIdentifiers},
})
if err != nil {
return err
}
if listObjectsOutput.IsTruncated == nil || !*listObjectsOutput.IsTruncated {
break
}
continuationToken = listObjectsOutput.NextContinuationToken
}
// Remove the previously created S3 bucket
_, err := s3Client.DeleteBucket(ctx, &s3.DeleteBucketInput{
Bucket: aws.String(data.Asset),
})
if err != nil {
if !strings.Contains(err.Error(), "NoSuchBucket") {
return fmt.Errorf("failed to delete S3 bucket %s: %w", data.Asset, err)
}
}
// Assign the new bucket name
data.Asset = value.Bucket
}
// Remove the SSM parameter
_, err = ssmClient.DeleteParameter(ctx, &ssm.DeleteParameterInput{
Name: aws.String(ssmKey),
})
if err != nil {
return fmt.Errorf("failed to delete SSM parameter %s: %w", ssmKey, err)
}
return nil
},
View on GitHub (pinned to a0bd20f762)
Solutions
- Empty the legacy asset bucket manually (`aws s3 rm s3://<bucket> --recursive`, and remove all object versions if versioned) then re-run `sst deploy`
- Check the bucket policy for an explicit Deny on `s3:DeleteBucket` (e.g. the SSL-enforcement policy) and the IAM/SCP permissions of the deploy role
- Verify the bucket region matches the configured AWS region
Defensive patterns
Strategy: retry
Validate before calling
aws s3api list-object-versions --bucket <legacy-asset-bucket> --max-items 5 # ensure bucket is fully empty before deploy
Try / catch
err := sstDeploy(ctx)
var delErr *s3types.NoSuchBucket
if err != nil && strings.Contains(err.Error(), "failed to delete S3 bucket") {
// empty all versions + delete markers, then retry
purgeAllVersions("legacy-asset-bucket")
err = sstDeploy(ctx)
} Prevention
- Fully empty legacy asset buckets (including versions) before upgrading SST
- Grant deploy role s3:DeleteBucket on sst-* buckets
- Check bucket policies don't deny s3:DeleteBucket
When it happens
Trigger: The legacy bucket is non-empty (versioning enabled leaves delete markers/versions the plain DeleteObjects pass does not remove), the credentials lack `s3:DeleteBucket`, or the bucket has a deny policy / region mismatch.
Common situations: Upgrading SST across the bootstrap change with a long-lived asset bucket that has versioning or leftover objects; SCP or bucket policy denying deletes.
Related errors
- At least one of function, queue, or topic is required for th
- Only one of function, queue, or topic is allowed for the "${
- Lifecycle rule at index ${index} has an empty or whitespace-
- failed to decode SSM parameter value: %w
- failed to delete SSM parameter %s: %w
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/18727bca7c5b7d20.
Report an issue: GitHub.