Skip to content

Commit

Permalink
🐛 aws: try govcloud region if default region does not work (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeffrey authored Jan 12, 2023
1 parent e887d6f commit 2934d0e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions motor/providers/aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,13 @@ func New(pCfg *providers.Config, opts ...ProviderOption) (*Provider, error) {
// gather information about the aws account
identity, err := CheckIam(t.config)
if err != nil {
log.Warn().Err(err).Msg("could not gather details of AWS account")
// do not error since this break with localstack
// try with govcloud region
t.config.Region = "us-gov-west-1"
identity, err = CheckIam(t.config)
if err != nil {
log.Warn().Err(err).Msg("could not gather details of AWS account")
// do not error since this break with localstack
}
} else {
t.info = Info{
Account: toString(identity.Account),
Expand Down Expand Up @@ -168,7 +173,12 @@ func (p *Provider) GetRegions() ([]string, error) {

res, err := svc.DescribeRegions(ctx, &ec2.DescribeRegionsInput{})
if err != nil {
return regions, nil
// try with govcloud region
svc := p.Ec2("us-gov-west-1")
res, err = svc.DescribeRegions(ctx, &ec2.DescribeRegionsInput{})
if err != nil {
return regions, err
}
}
for _, region := range res.Regions {
regions = append(regions, *region.RegionName)
Expand Down

0 comments on commit 2934d0e

Please sign in to comment.