Skip to content

Commit

Permalink
Allow auth by role in aws
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicola Strappazzon C committed Feb 28, 2023
1 parent 7eab095 commit ed8271e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
2 changes: 0 additions & 2 deletions command/example/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ general:
interval: 10 # Seconds
debug: true
aws_region: ${AWS_REGION}
aws_access_key_id: ${AWS_ACCESS_KEY_ID}
aws_secret_access_key: ${AWS_SECRET_ACCESS_KEY}
parser:
mysql:
Expand Down
10 changes: 4 additions & 6 deletions config/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ type Config struct {
Path string
IPAddress string
General struct {
Hostname string `yaml:"hostname"`
Interval time.Duration `yaml:"interval"`
Debug bool `yaml:"debug"`
AWSRegion string `yaml:"aws_region"`
AWSAccessKeyID string `yaml:"aws_access_key_id"`
AWSSecretAccessKey string `yaml:"aws_secret_access_key"`
Hostname string `yaml:"hostname"`
Interval time.Duration `yaml:"interval"`
Debug bool `yaml:"debug"`
AWSRegion string `yaml:"aws_region"`
}
Parser struct {
MySQL struct {
Expand Down
20 changes: 2 additions & 18 deletions plugins/inputs/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/debeando/zenit/plugins/inputs"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/rds"
)
Expand Down Expand Up @@ -50,25 +49,10 @@ func (l *InputAWSDiscover) Collect() {
return
}

if len(config.File.General.AWSAccessKeyID) == 0 {
log.Info("InputAWSDiscover", map[string]interface{}{"message": "Require to define aws_access_key_id"})
return
}

if len(config.File.General.AWSSecretAccessKey) == 0 {
log.Info("InputAWSDiscover", map[string]interface{}{"message": "Require to define aws_secret_access_key"})
return
}

sess, err := session.NewSession(&aws.Config{
Region: aws.String(config.File.General.AWSRegion),
Credentials: credentials.NewStaticCredentials(
config.File.General.AWSAccessKeyID,
config.File.General.AWSSecretAccessKey,
"",
),
},
)
})

if err != nil {
log.Error("InputAWSDiscover", map[string]interface{}{"error": err})
return
Expand Down

0 comments on commit ed8271e

Please sign in to comment.