mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(s3): make us-east-1 bucket creation idempotent (#844)
This commit is contained in:
1 parent
5cae86fc4d
commit
a396110cb5
3 files changed
+22
-6
No files matched your search
@@ -157,6 +157,11 @@ public class S3Service {
|
||||
public Bucket createBucket(String bucketName, String region) {
|
||||
var existing = bucketStore.get(bucketName);
|
||||
if (existing.isPresent()) {
|
||||
Bucket bucket = existing.get();
|
||||
if (isDefaultS3Region(bucket.getRegion()) && isDefaultS3Region(region)) {
|
||||
LOG.infov("Bucket already exists in default region, treating CreateBucket as idempotent: {0}", bucketName);
|
||||
return bucket;
|
||||
}
|
||||
throw new AwsException("BucketAlreadyOwnedByYou",
|
||||
"Your previous request to create the named bucket succeeded and you already own it.", 409);
|
||||
}
|
||||
@@ -168,6 +173,10 @@ public class S3Service {
|
||||
return bucket;
|
||||
}
|
||||
|
||||
private static boolean isDefaultS3Region(String region) {
|
||||
return region == null || region.isBlank() || "us-east-1".equalsIgnoreCase(region);
|
||||
}
|
||||
|
||||
public void deleteBucket(String bucketName) {
|
||||
ensureBucketExists(bucketName);
|
||||
|
||||
|
||||
Reference in new issue
Block a user