Skip to content

Commit

Permalink
Merge pull request #107 from lnguyen1401/ODS-7302
Browse files Browse the repository at this point in the history
fixed the region problem for : osdctl account cli -i  -o env
  • Loading branch information
openshift-merge-robot authored Jun 22, 2021
2 parents 1137c81 + c534db4 commit f41494d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
18 changes: 10 additions & 8 deletions pkg/k8s/clusterresourcefactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"

"strings"

"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -91,12 +92,6 @@ func (factory *ClusterResourceFactoryOptions) GetCloudProvider(verbose bool) (aw
}
}

var err error
awsClient, err := factory.Awscloudfactory.NewAwsClient()
if err != nil {
return nil, err
}

supportRoleDefined := false

ctx := context.TODO()
Expand All @@ -118,6 +113,14 @@ func (factory *ClusterResourceFactoryOptions) GetCloudProvider(verbose bool) (aw
supportRoleDefined = true
}
}
factory.Awscloudfactory.Region = accountClaim.Spec.Aws.Regions[0].Name

var err error
awsClient, err := factory.Awscloudfactory.NewAwsClient()
if err != nil {
return nil, err
}

var isBYOC bool
var acctSuffix string
if factory.AccountName != "" {
Expand Down Expand Up @@ -222,12 +225,11 @@ func (factory *ClusterResourceFactoryOptions) GetCloudProvider(verbose bool) (aw
return nil, err
}
}

awsClient, err = awsprovider.NewAwsClientWithInput(&awsprovider.AwsClientInput{
AccessKeyID: *factory.Awscloudfactory.Credentials.AccessKeyId,
SecretAccessKey: *factory.Awscloudfactory.Credentials.SecretAccessKey,
SessionToken: *factory.Awscloudfactory.Credentials.SessionToken,
Region: factory.Awscloudfactory.Region,
Region: accountClaim.Spec.Aws.Regions[0].Name,
})
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion pkg/provider/aws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ package aws

import (
"fmt"
"path/filepath"

"github.com/aws/aws-sdk-go/service/costexplorer"
"github.com/aws/aws-sdk-go/service/costexplorer/costexploreriface"
"github.com/aws/aws-sdk-go/service/organizations"
"github.com/aws/aws-sdk-go/service/organizations/organizationsiface"
"path/filepath"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
Expand Down

0 comments on commit f41494d

Please sign in to comment.