Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete migration to AWS Go client V2. #216

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions aws-janitor/resources/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"net/http"
"strings"

"github.com/aws/aws-sdk-go/aws/awserr"
awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand All @@ -47,8 +47,11 @@ func CleanAll(opts Options, region string) error {
set, err := typ.ListAll(opts)
if err != nil {
// ignore errors for resources we do not have permissions to list
if reqerr, ok := errors.Cause(err).(awserr.RequestFailure); ok {
if reqerr.StatusCode() == http.StatusForbidden {
if resperr, ok := errors.Cause(err).(*awshttp.ResponseError); ok {
var responseError interface {
HTTPStatusCode() int
}
if resperr.As(&responseError) && responseError.HTTPStatusCode() == http.StatusForbidden {
logger.Debugf("Skipping resources of type %T, account does not have permission to list", typ)
continue
}
Expand Down
8 changes: 4 additions & 4 deletions aws-janitor/resources/s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func (S3Bucket) MarkAndSweep(opts Options, set *Set) error {
opt.Region = opts.Region
})

// ListBucket lists all buckets owned by the authenticated sender of the request
// https://pkg.go.dev/github.com/aws/aws-sdk-go/service/s3#S3.ListBuckets
// ListBuckets lists all buckets owned by the authenticated sender of the request
// https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/s3#Client.ListBuckets
// regardless the region configured in client.
resp, err := svc.ListBuckets(context.TODO(), &s3v2.ListBucketsInput{})
if err != nil {
Expand Down Expand Up @@ -130,8 +130,8 @@ func (S3Bucket) ListAll(opts Options) (*Set, error) {
opt.Region = opts.Region
})

// ListBucket lists all buckets owned by the authenticated sender of the request
// https://pkg.go.dev/github.com/aws/aws-sdk-go/service/s3#S3.ListBuckets
// ListBuckets lists all buckets owned by the authenticated sender of the request
// https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/s3#Client.ListBuckets
// regardless the region configured in client.
resp, err := svc.ListBuckets(context.TODO(), &s3v2.ListBucketsInput{})
if err != nil {
Expand Down