Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⭐ Add discovery for aws-rds-dbcluster #3027

Merged
merged 1 commit into from
Jan 21, 2024
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
1 change: 1 addition & 0 deletions providers/aws/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var Config = plugin.Provider{
resources.DiscoveryS3Buckets,
resources.DiscoveryCloudtrailTrails,
resources.DiscoveryRdsDbInstances,
resources.DiscoveryRdsDbClusters,
resources.DiscoveryVPCs,
resources.DiscoverySecurityGroups,
resources.DiscoveryIAMUsers,
Expand Down
2 changes: 2 additions & 0 deletions providers/aws/connection/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func getTitleForPlatformName(name string) string {
return "AWS CloudTrail Trail"
case "aws-rds-dbinstance":
return "AWS RDS DB Instance"
case "aws-rds-dbcluster":
return "AWS RDS DB Cluster"
case "aws-dynamodb-table":
return "AWS DynamoDB Table"
case "aws-redshift-cluster":
Expand Down
28 changes: 28 additions & 0 deletions providers/aws/resources/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
DiscoveryS3Buckets = "s3-buckets"
DiscoveryCloudtrailTrails = "cloudtrail-trails"
DiscoveryRdsDbInstances = "rds-dbinstances"
DiscoveryRdsDbClusters = "rds-dbclusters"
DiscoveryVPCs = "vpcs"
DiscoverySecurityGroups = "security-groups"
DiscoveryIAMUsers = "iam-users"
Expand Down Expand Up @@ -71,6 +72,7 @@ var AllAPIResources = []string{
DiscoveryS3Buckets,
DiscoveryCloudtrailTrails,
DiscoveryRdsDbInstances,
DiscoveryRdsDbClusters,
DiscoveryVPCs,
DiscoverySecurityGroups,
DiscoveryIAMUsers,
Expand Down Expand Up @@ -525,6 +527,32 @@ func discover(runtime *plugin.Runtime, awsAccount *mqlAwsAccount, target string,
}
assetList = append(assetList, MqlObjectToAsset(accountId, m, conn))
}
case DiscoveryRdsDbClusters:
res, err := NewResource(runtime, "aws.rds", map[string]*llx.RawData{})
if err != nil {
return nil, err
}

r := res.(*mqlAwsRds)

clusters := r.GetDbClusters()
if clusters == nil {
return assetList, nil
}

for i := range clusters.Data {
f := clusters.Data[i].(*mqlAwsRdsDbcluster)

tags := mapStringInterfaceToStringString(f.Tags.Data)
m := mqlObject{
name: f.Id.Data, labels: tags,
awsObject: awsObject{
account: accountId, region: f.Region.Data, arn: f.Arn.Data,
id: f.Id.Data, service: "rds", objectType: "dbcluster",
},
}
assetList = append(assetList, MqlObjectToAsset(accountId, m, conn))
}
case DiscoveryVPCs:
res, err := NewResource(runtime, "aws", map[string]*llx.RawData{})
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions providers/aws/resources/discovery_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ func getPlatformName(awsObject awsObject) string {
if awsObject.objectType == "dbinstance" {
return "aws-rds-dbinstance"
}
if awsObject.objectType == "dbcluster" {
return "aws-rds-dbcluster"
}
case "dynamodb":
if awsObject.objectType == "table" {
return "aws-dynamodb-table"
Expand Down
Loading