Skip to content

Commit

Permalink
Add new properties to aws.rds.dbInstances
Browse files Browse the repository at this point in the history
Add a few important things for asset inventory.
- Storage type
- Storage IOPS
- Storage amount allocated
- Engine Version
- Availability zone
- Creation Date

Signed-off-by: Tim Smith <[email protected]>
  • Loading branch information
tas50 committed Oct 2, 2023
1 parent 2cf293a commit 999ae27
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 12 deletions.
14 changes: 13 additions & 1 deletion providers/aws/resources/aws.lr
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ private aws.rds.snapshot @defaults("arn") {
}

// Amazon RDS Database Instance
private aws.rds.dbinstance @defaults("arn") {
private aws.rds.dbinstance @defaults("id region engine engineVersion") {
// ARN for the database instance
arn string
// Name of the database instance
Expand All @@ -1215,8 +1215,16 @@ private aws.rds.dbinstance @defaults("arn") {
snapshots() []aws.rds.snapshot
// Denotes whether the instance is encrypted
storageEncrypted bool
// The amount of storage, in GiB, provisioned on the instance
storageAllocated int
// The storage IOPS provisioned on the instance
storageIops int
// The type of storage provisioned on the instance
storageType string
// Region where the instance exists
region string
// Availability zone where the instance exists
availabilityZone string
// Denotes whether or not the instance is publicly accessible
publiclyAccessible bool
// List of log types the instance is configured to export to cloudwatch logs
Expand All @@ -1237,12 +1245,16 @@ private aws.rds.dbinstance @defaults("arn") {
dbInstanceIdentifier string
// Name of the database engine for this DB instance
engine string
// The version of the database engine for this DB instance
engineVersion string
// List of VPC security group elements that the DB instance belongs to
securityGroups []aws.ec2.securitygroup
// Current state of this database
status string
// Indicates whether minor version patches are applied automatically
autoMinorVersionUpgrade bool
// The creation date of the RDS instance
creationDate time
}

// Amazon ElastiCache
Expand Down
72 changes: 72 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.

12 changes: 12 additions & 0 deletions providers/aws/resources/aws.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,11 @@ resources:
arn: {}
autoMinorVersionUpgrade:
min_mondoo_version: 8.22.0
availabilityZone:
min_mondoo_version: 9.0.0
backupRetentionPeriod: {}
creationDate:
min_mondoo_version: 9.0.0
dbInstanceClass:
min_mondoo_version: 5.19.1
dbInstanceIdentifier:
Expand All @@ -1811,6 +1815,8 @@ resources:
enabledCloudwatchLogsExports: {}
engine:
min_mondoo_version: 5.19.1
engineVersion:
min_mondoo_version: 9.0.0
enhancedMonitoringResourceArn: {}
id: {}
multiAZ: {}
Expand All @@ -1822,7 +1828,13 @@ resources:
snapshots: {}
status:
min_mondoo_version: 5.19.1
storageAllocated:
min_mondoo_version: 9.0.0
storageEncrypted: {}
storageIops:
min_mondoo_version: 9.0.0
storageType:
min_mondoo_version: 9.0.0
tags: {}
is_private: true
min_mondoo_version: 5.15.0
Expand Down
28 changes: 17 additions & 11 deletions providers/aws/resources/aws_rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,29 @@ func (a *mqlAwsRds) getDbInstances(conn *connection.AwsConnection) []*jobpool.Jo
mqlDBInstance, err := CreateResource(a.MqlRuntime, "aws.rds.dbinstance",
map[string]*llx.RawData{
"arn": llx.StringData(convert.ToString(dbInstance.DBInstanceArn)),
"name": llx.StringData(convert.ToString(dbInstance.DBName)),
"autoMinorVersionUpgrade": llx.BoolData(dbInstance.AutoMinorVersionUpgrade),
"availabilityZone": llx.StringData(convert.ToString(dbInstance.AvailabilityZone)),
"backupRetentionPeriod": llx.IntData(int64(dbInstance.BackupRetentionPeriod)),
"storageEncrypted": llx.BoolData(dbInstance.StorageEncrypted),
"region": llx.StringData(regionVal),
"publiclyAccessible": llx.BoolData(dbInstance.PubliclyAccessible),
"enabledCloudwatchLogsExports": llx.ArrayData(stringSliceInterface, types.String),
"enhancedMonitoringResourceArn": llx.StringData(convert.ToString(dbInstance.EnhancedMonitoringResourceArn)),
"multiAZ": llx.BoolData(dbInstance.MultiAZ),
"id": llx.StringData(convert.ToString(dbInstance.DBInstanceIdentifier)),
"deletionProtection": llx.BoolData(dbInstance.DeletionProtection),
"tags": llx.MapData(rdsTagsToMap(dbInstance.TagList), types.String),
"dbInstanceClass": llx.StringData(convert.ToString(dbInstance.DBInstanceClass)),
"dbInstanceIdentifier": llx.StringData(convert.ToString(dbInstance.DBInstanceIdentifier)),
"deletionProtection": llx.BoolData(dbInstance.DeletionProtection),
"enabledCloudwatchLogsExports": llx.ArrayData(stringSliceInterface, types.String),
"engine": llx.StringData(convert.ToString(dbInstance.Engine)),
"engineVersion": llx.StringData(convert.ToString(dbInstance.EngineVersion)),
"enhancedMonitoringResourceArn": llx.StringData(convert.ToString(dbInstance.EnhancedMonitoringResourceArn)),
"id": llx.StringData(convert.ToString(dbInstance.DBInstanceIdentifier)),
"multiAZ": llx.BoolData(dbInstance.MultiAZ),
"name": llx.StringData(convert.ToString(dbInstance.DBName)),
"publiclyAccessible": llx.BoolData(dbInstance.PubliclyAccessible),
"region": llx.StringData(regionVal),
"securityGroups": llx.ArrayData(sgs, types.Resource("aws.ec2.securitygroup")),
"status": llx.StringData(convert.ToString(dbInstance.DBInstanceStatus)),
"autoMinorVersionUpgrade": llx.BoolData(dbInstance.AutoMinorVersionUpgrade),
"storageAllocated": llx.IntData(int64(dbInstance.AllocatedStorage)),
"storageEncrypted": llx.BoolData(dbInstance.StorageEncrypted),
"storageType": llx.StringData(convert.ToString(dbInstance.StorageType)),
"storageIops": llx.IntData(convert.ToInt64From32(dbInstance.Iops)),
"tags": llx.MapData(rdsTagsToMap(dbInstance.TagList), types.String),
"creationDate": llx.TimeData(toTime(dbInstance.InstanceCreateTime)),
})
if err != nil {
return nil, err
Expand Down

0 comments on commit 999ae27

Please sign in to comment.