terraform/provider: do not adopt a bucket owned by another identity

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-12-05 14:19:18 -08:00
1 parent 7c2501f44c
commit 607f1c9d4b
2 files changed
+4 -1

No files matched your search

+1 -1
View File
@@ -591,7 +591,7 @@ func isNoSuchBucketError(err error) bool {
func isBucketAlreadyExistsError(err error) bool {
var apiErr iamError
if errors.As(err, &apiErr) {
return apiErr.Code == "BucketAlreadyOwnedByYou" || apiErr.Code == "BucketAlreadyExists"
return apiErr.Code == "BucketAlreadyOwnedByYou"
}
return false
}
@@ -496,6 +496,9 @@ func TestIAMErrorHelpers(t *testing.T) {
if !isEntityAlreadyExistsError(iamError{Code: "EntityAlreadyExists", Message: "exists"}) {
t.Fatalf("expected EntityAlreadyExists helper to match")
}
if isBucketAlreadyExistsError(iamError{Code: "BucketAlreadyExists", Message: "taken"}) {
t.Fatal("a bucket owned by another identity must not be adopted")
}
if !isBucketAlreadyExistsError(iamError{Code: "BucketAlreadyOwnedByYou", Message: "exists"}) {
t.Fatalf("expected BucketAlreadyOwnedByYou helper to match")
}