Skip to content

Commit

Permalink
fix(treasury): invalid SSM client construction
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolodziejczykmaciek committed Jan 27, 2025
1 parent 7b6966f commit b7da9dc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func New(options Options) (BackendAPI, error) {
case s3Name:
return s3.New(options.Region, options.S3BucketName)
case ssmName:
return ssm.New(options.Region, options.AWSConfig)
return ssm.New(options.AWSConfig)
}
return nil, errors.New("invalid backend")
}
11 changes: 2 additions & 9 deletions backend/ssm/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package ssm

import (
"context"
"fmt"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/ssm"
)

Expand All @@ -21,13 +19,8 @@ type Client struct {
svc SSMClientInterface
}

func New(region string, awsConfig aws.Config) (*Client, error) {
cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRegion(region))
if err != nil {
return nil, fmt.Errorf("failed to load AWS configuration. Error: %s", err)
}

func New(awsConfig aws.Config) (*Client, error) {
return &Client{
svc: ssm.NewFromConfig(cfg),
svc: ssm.NewFromConfig(awsConfig),
}, nil
}
2 changes: 1 addition & 1 deletion backend/ssm/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestNew(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := ssm.New(tt.region, tt.config)
_, err := ssm.New(tt.config)
if (err != nil) != tt.wantErr {
t.Errorf("New() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down

0 comments on commit b7da9dc

Please sign in to comment.