Skip to content

Commit

Permalink
scaler(aws_ec2_asg): added region to the ec2_asg config (#25)
Browse files Browse the repository at this point in the history
* added region to the ec2_asg config

* added aws region check

* Update internal/scaler/awsec2asg/aws_ec2_asg.go

Co-authored-by: Vishnu Bharathi <[email protected]>

---------

Co-authored-by: Vishnu Bharathi <[email protected]>
  • Loading branch information
krishnaduttPanchagnula and scriptnull authored May 31, 2023
1 parent e9bbd73 commit 4795561
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions internal/scaler/awsec2asg/aws_ec2_asg.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/aws/aws-sdk-go/service/ec2"
Expand All @@ -15,13 +16,15 @@ import (
"github.com/scriptnull/waymond/internal/scaler"
)

const Type scaler.Type = "aws_ec2_asg"
const (
Type scaler.Type = "aws_ec2_asg"
)

type Scaler struct {
ID string `koanf:"id"`
namespacedID string
log log.Logger

ID string `koanf:"id"`
namespacedID string
log log.Logger
Region *string `koanf:"region"`
AllowCreate bool `koanf:"allow_create"`
DisableScaleIn *bool `koanf:"disable_scale_in"`
DisableScaleOut *bool `koanf:"disable_scale_out"`
Expand Down Expand Up @@ -82,7 +85,13 @@ func (s *Scaler) Type() scaler.Type {
}

func (s *Scaler) Register(ctx context.Context) error {
sess, err := session.NewSession()
var sessConfigs []*aws.Config
if s.Region != nil {
sessConfigs = append(sessConfigs, &aws.Config{
Region: s.Region,
})
}
sess, err := session.NewSession(sessConfigs...)
if err != nil {
return err
}
Expand Down

0 comments on commit 4795561

Please sign in to comment.