mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
ignore AccessDenied error on listing workspaces in S3 (#1445)
Signed-off-by: ollevche <ollevche@gmail.com>
This commit is contained in:
committed by
GitHub
parent
969a7e0a99
commit
02e12d054e
@@ -16,6 +16,7 @@ import (
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||
types "github.com/aws/aws-sdk-go-v2/service/s3/types"
|
||||
"github.com/aws/smithy-go"
|
||||
|
||||
"github.com/opentofu/opentofu/internal/backend"
|
||||
"github.com/opentofu/opentofu/internal/states"
|
||||
@@ -48,11 +49,18 @@ func (b *Backend) Workspaces() ([]string, error) {
|
||||
for pg.HasMorePages() {
|
||||
page, err := pg.NextPage(ctx)
|
||||
if err != nil {
|
||||
var e *types.NoSuchBucket
|
||||
if errors.As(err, &e) {
|
||||
var noBucketErr *types.NoSuchBucket
|
||||
if errors.As(err, &noBucketErr) {
|
||||
return nil, fmt.Errorf(errS3NoSuchBucket, err)
|
||||
}
|
||||
|
||||
// Ignoring AccessDenied errors for backward compatibility,
|
||||
// since it should work for default state when no other workspaces present.
|
||||
var apiErr smithy.APIError
|
||||
if errors.As(err, &apiErr) && apiErr.ErrorCode() == "AccessDenied" {
|
||||
break
|
||||
}
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user