Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions models/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ var databaseSchema = [][]string{
ADD COLUMN mysql_disable_tablestats TINYINT(1)
`,
},

4: {
`ALTER TABLE nodes
DROP COLUMN aws_dbi_resource_id
`,
},
}

func OpenDB(name, username, password string, logf reform.Printf) (*sql.DB, error) {
Expand Down
3 changes: 1 addition & 2 deletions models/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@ type RDSNode struct {
Type NodeType `reform:"type"`
Name string `reform:"name"` // DBInstanceIdentifier

Region string `reform:"region"` // not a pointer, see database structure
AWSDBIResourceID *string `reform:"aws_dbi_resource_id"`
Region string `reform:"region"` // not a pointer, see database structure
}
9 changes: 3 additions & 6 deletions models/node_reform.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions services/rds/rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ func (svc *Service) Discover(ctx context.Context, accessKey, secretKey string) (
Type: models.RDSNodeType,
Name: *db.DBInstanceIdentifier,

Region: region,
AWSDBIResourceID: db.DbiResourceId,
Region: region,
},
Service: models.RDSService{
Type: models.RDSServiceType,
Expand Down
11 changes: 5 additions & 6 deletions services/rds/rds_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ const (
)

type rdsExporterInstance struct {
Region string `yaml:"region"`
Instance string `yaml:"instance"`
DBIResourceID *string `yaml:"dbi_resource_id,omitempty"`
Type instanceType `yaml:"type"`
AWSAccessKey *string `yaml:"aws_access_key,omitempty"`
AWSSecretKey *string `yaml:"aws_secret_key,omitempty"`
Region string `yaml:"region"`
Instance string `yaml:"instance"`
Type instanceType `yaml:"type"`
AWSAccessKey *string `yaml:"aws_access_key,omitempty"`
AWSSecretKey *string `yaml:"aws_secret_key,omitempty"`
}

type rdsExporterConfig struct {
Expand Down
36 changes: 16 additions & 20 deletions services/rds/rds_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,28 @@ func TestRDSExporterMarshal(t *testing.T) {
cfg := &rdsExporterConfig{
Instances: []rdsExporterInstance{
{
Region: "us-east-1",
Instance: "rds-aurora1",
DBIResourceID: pointer.ToString("db-P5QCHK64NWDD5BLLBVT5NPQS2Q"),
Type: auroraMySQL,
Region: "us-east-1",
Instance: "rds-aurora1",
Type: auroraMySQL,
},
{
Region: "us-east-1",
Instance: "rds-aurora57",
DBIResourceID: pointer.ToString("db-CDBSN4EK5SMBQCSXI4UPZVF3W4"),
Type: auroraMySQL,
AWSAccessKey: pointer.ToString("AKIAIOSFODNN7EXAMPLE"),
AWSSecretKey: pointer.ToString("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
Region: "us-east-1",
Instance: "rds-aurora57",
Type: auroraMySQL,
AWSAccessKey: pointer.ToString("AKIAIOSFODNN7EXAMPLE"),
AWSSecretKey: pointer.ToString("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
},
{
Region: "us-east-1",
Instance: "rds-mysql56",
DBIResourceID: pointer.ToString("db-J6JH3LJAWBZ6MXDDWYRG4RRJ6A"),
Type: mySQL,
Region: "us-east-1",
Instance: "rds-mysql56",
Type: mySQL,
},
{
Region: "us-east-1",
Instance: "rds-mysql57",
DBIResourceID: pointer.ToString("db-FE4Y2GIJU6UADBOXKULV3DBATY"),
Type: mySQL,
AWSAccessKey: pointer.ToString("AKIAIOSFODNN7EXAMPLE"),
AWSSecretKey: pointer.ToString("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
Region: "us-east-1",
Instance: "rds-mysql57",
Type: mySQL,
AWSAccessKey: pointer.ToString("AKIAIOSFODNN7EXAMPLE"),
AWSSecretKey: pointer.ToString("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
},
},
}
Expand Down
28 changes: 12 additions & 16 deletions services/rds/rds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,9 @@ func TestDiscover(t *testing.T) {
require.NoError(t, err)
expected := []Instance{{
Node: models.RDSNode{
Type: "rds",
Name: "rds-aurora1",
Region: "us-east-1",
AWSDBIResourceID: pointer.ToString("db-P5QCHK64NWDD5BLLBVT5NPQS2Q"),
Type: "rds",
Name: "rds-aurora1",
Region: "us-east-1",
},
Service: models.RDSService{
Type: "rds",
Expand All @@ -189,10 +188,9 @@ func TestDiscover(t *testing.T) {
},
}, {
Node: models.RDSNode{
Type: "rds",
Name: "rds-aurora57",
Region: "us-east-1",
AWSDBIResourceID: pointer.ToString("db-CDBSN4EK5SMBQCSXI4UPZVF3W4"),
Type: "rds",
Name: "rds-aurora57",
Region: "us-east-1",
},
Service: models.RDSService{
Type: "rds",
Expand All @@ -203,10 +201,9 @@ func TestDiscover(t *testing.T) {
},
}, {
Node: models.RDSNode{
Type: "rds",
Name: "rds-mysql56",
Region: "us-east-1",
AWSDBIResourceID: pointer.ToString("db-J6JH3LJAWBZ6MXDDWYRG4RRJ6A"),
Type: "rds",
Name: "rds-mysql56",
Region: "us-east-1",
},
Service: models.RDSService{
Type: "rds",
Expand All @@ -217,10 +214,9 @@ func TestDiscover(t *testing.T) {
},
}, {
Node: models.RDSNode{
Type: "rds",
Name: "rds-mysql57",
Region: "us-east-1",
AWSDBIResourceID: pointer.ToString("db-FE4Y2GIJU6UADBOXKULV3DBATY"),
Type: "rds",
Name: "rds-mysql57",
Region: "us-east-1",
},
Service: models.RDSService{
Type: "rds",
Expand Down
4 changes: 0 additions & 4 deletions testdata/rds_exporter/rds_exporter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@
instances:
- region: us-east-1
instance: rds-aurora1
dbi_resource_id: db-P5QCHK64NWDD5BLLBVT5NPQS2Q
type: aurora_mysql
- region: us-east-1
instance: rds-aurora57
dbi_resource_id: db-CDBSN4EK5SMBQCSXI4UPZVF3W4
type: aurora_mysql
aws_access_key: AKIAIOSFODNN7EXAMPLE
aws_secret_key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
- region: us-east-1
instance: rds-mysql56
dbi_resource_id: db-J6JH3LJAWBZ6MXDDWYRG4RRJ6A
type: mysql
- region: us-east-1
instance: rds-mysql57
dbi_resource_id: db-FE4Y2GIJU6UADBOXKULV3DBATY
type: mysql
aws_access_key: AKIAIOSFODNN7EXAMPLE
aws_secret_key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY