Skip to content

Commit

Permalink
Add security group to aws.rds.dbcluster (#2843)
Browse files Browse the repository at this point in the history
This is a copy/modification of the same logic we use for the dbinstance
resource

Signed-off-by: Tim Smith <[email protected]>
  • Loading branch information
tas50 authored Dec 19, 2023
1 parent c3e7501 commit d328eab
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions providers/aws/resources/aws.lr
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,8 @@ private aws.rds.dbcluster @defaults("id region") {
multiAZ bool
// Whether deletion protection is enabled
deletionProtection bool
// List of VPC security group elements that the DB cluster belongs to
securityGroups []aws.ec2.securitygroup
}

// Amazon RDS snapshot
Expand Down
12 changes: 12 additions & 0 deletions providers/aws/resources/aws.lr.go

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

2 changes: 2 additions & 0 deletions providers/aws/resources/aws.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1921,6 +1921,8 @@ resources:
publiclyAccessible:
min_mondoo_version: 9.0.0
region: {}
securityGroups:
min_mondoo_version: 9.0.0
snapshots: {}
status:
min_mondoo_version: 9.0.0
Expand Down
13 changes: 13 additions & 0 deletions providers/aws/resources/aws_rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ func (a *mqlAwsRds) getDbClusters(conn *connection.AwsConnection) []*jobpool.Job
// }
// mqlRdsDbInstances = append(mqlRdsDbInstances, mqlInstance)
// }
sgs := []interface{}{}
for i := range cluster.VpcSecurityGroups {
// NOTE: this will create the resource and determine the data in its init method
mqlSg, err := NewResource(a.MqlRuntime, "aws.ec2.securitygroup",
map[string]*llx.RawData{
"arn": llx.StringData(fmt.Sprintf(securityGroupArnPattern, regionVal, conn.AccountId(), convert.ToString(cluster.VpcSecurityGroups[i].VpcSecurityGroupId))),
})
if err != nil {
return nil, err
}
sgs = append(sgs, mqlSg.(*mqlAwsEc2Securitygroup))
}
mqlDbCluster, err := CreateResource(a.MqlRuntime, "aws.rds.dbcluster",
map[string]*llx.RawData{
"arn": llx.StringDataPtr(cluster.DBClusterArn),
Expand All @@ -258,6 +270,7 @@ func (a *mqlAwsRds) getDbClusters(conn *connection.AwsConnection) []*jobpool.Job
"storageIops": llx.IntData(convert.ToInt64From32(cluster.Iops)),
"storageType": llx.StringDataPtr(cluster.StorageType),
"tags": llx.MapData(rdsTagsToMap(cluster.TagList), types.String),
"securityGroups": llx.ArrayData(sgs, types.Resource("aws.ec2.securitygroup")),
// "members": mqlRdsDbInstances,
})
if err != nil {
Expand Down

0 comments on commit d328eab

Please sign in to comment.