From fa7d454015b811bceb194d858a5ee861cb129d93 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Tue, 26 Mar 2024 06:24:28 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20new=20fields=20for=20AWS=20RD?= =?UTF-8?q?S=20DB=20instances=20and=20clusters=20(#3634)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - hostedZoneId - masterUsername - latestRestorableTime Signed-off-by: Tim Smith --- providers/aws/resources/aws.lr | 10 ++++ providers/aws/resources/aws.lr.go | 60 ++++++++++++++++++++ providers/aws/resources/aws.lr.manifest.yaml | 12 +++- providers/aws/resources/aws_rds.go | 7 ++- 4 files changed, 87 insertions(+), 2 deletions(-) diff --git a/providers/aws/resources/aws.lr b/providers/aws/resources/aws.lr index e84ccf272f..22b82c5d12 100644 --- a/providers/aws/resources/aws.lr +++ b/providers/aws/resources/aws.lr @@ -1828,6 +1828,12 @@ private aws.rds.dbcluster @defaults("id region") { port int // The connection endpoint for the primary instance of the DB cluster endpoint string + // The cluster hosted zone ID + hostedZoneId string + // The master username for the DB instance + masterUsername string + // The latest time to which a database can be restored with point-in-time restore + latestRestorableTime time } // Amazon RDS snapshot @@ -1918,6 +1924,10 @@ private aws.rds.dbinstance @defaults("id region engine engineVersion") { port int // The connection endpoint for the DB instance endpoint string + // The master username for the DB instance + masterUsername string + // The latest time to which a database can be restored with point-in-time restore + latestRestorableTime time } // Amazon ElastiCache diff --git a/providers/aws/resources/aws.lr.go b/providers/aws/resources/aws.lr.go index e1cf0d669f..59fa9d7198 100644 --- a/providers/aws/resources/aws.lr.go +++ b/providers/aws/resources/aws.lr.go @@ -2720,6 +2720,15 @@ var getDataFields = map[string]func(r plugin.Resource) *plugin.DataRes{ "aws.rds.dbcluster.endpoint": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlAwsRdsDbcluster).GetEndpoint()).ToDataRes(types.String) }, + "aws.rds.dbcluster.hostedZoneId": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlAwsRdsDbcluster).GetHostedZoneId()).ToDataRes(types.String) + }, + "aws.rds.dbcluster.masterUsername": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlAwsRdsDbcluster).GetMasterUsername()).ToDataRes(types.String) + }, + "aws.rds.dbcluster.latestRestorableTime": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlAwsRdsDbcluster).GetLatestRestorableTime()).ToDataRes(types.Time) + }, "aws.rds.snapshot.arn": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlAwsRdsSnapshot).GetArn()).ToDataRes(types.String) }, @@ -2843,6 +2852,12 @@ var getDataFields = map[string]func(r plugin.Resource) *plugin.DataRes{ "aws.rds.dbinstance.endpoint": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlAwsRdsDbinstance).GetEndpoint()).ToDataRes(types.String) }, + "aws.rds.dbinstance.masterUsername": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlAwsRdsDbinstance).GetMasterUsername()).ToDataRes(types.String) + }, + "aws.rds.dbinstance.latestRestorableTime": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlAwsRdsDbinstance).GetLatestRestorableTime()).ToDataRes(types.Time) + }, "aws.elasticache.clusters": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlAwsElasticache).GetClusters()).ToDataRes(types.Array(types.Dict)) }, @@ -6823,6 +6838,18 @@ var setDataFields = map[string]func(r plugin.Resource, v *llx.RawData) bool { r.(*mqlAwsRdsDbcluster).Endpoint, ok = plugin.RawToTValue[string](v.Value, v.Error) return }, + "aws.rds.dbcluster.hostedZoneId": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlAwsRdsDbcluster).HostedZoneId, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "aws.rds.dbcluster.masterUsername": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlAwsRdsDbcluster).MasterUsername, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "aws.rds.dbcluster.latestRestorableTime": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlAwsRdsDbcluster).LatestRestorableTime, ok = plugin.RawToTValue[*time.Time](v.Value, v.Error) + return + }, "aws.rds.snapshot.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { r.(*mqlAwsRdsSnapshot).__id, ok = v.Value.(string) return @@ -6995,6 +7022,14 @@ var setDataFields = map[string]func(r plugin.Resource, v *llx.RawData) bool { r.(*mqlAwsRdsDbinstance).Endpoint, ok = plugin.RawToTValue[string](v.Value, v.Error) return }, + "aws.rds.dbinstance.masterUsername": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlAwsRdsDbinstance).MasterUsername, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "aws.rds.dbinstance.latestRestorableTime": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlAwsRdsDbinstance).LatestRestorableTime, ok = plugin.RawToTValue[*time.Time](v.Value, v.Error) + return + }, "aws.elasticache.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { r.(*mqlAwsElasticache).__id, ok = v.Value.(string) return @@ -17702,6 +17737,9 @@ type mqlAwsRdsDbcluster struct { AvailabilityZones plugin.TValue[[]interface{}] Port plugin.TValue[int64] Endpoint plugin.TValue[string] + HostedZoneId plugin.TValue[string] + MasterUsername plugin.TValue[string] + LatestRestorableTime plugin.TValue[*time.Time] } // createAwsRdsDbcluster creates a new instance of this resource @@ -17849,6 +17887,18 @@ func (c *mqlAwsRdsDbcluster) GetEndpoint() *plugin.TValue[string] { return &c.Endpoint } +func (c *mqlAwsRdsDbcluster) GetHostedZoneId() *plugin.TValue[string] { + return &c.HostedZoneId +} + +func (c *mqlAwsRdsDbcluster) GetMasterUsername() *plugin.TValue[string] { + return &c.MasterUsername +} + +func (c *mqlAwsRdsDbcluster) GetLatestRestorableTime() *plugin.TValue[*time.Time] { + return &c.LatestRestorableTime +} + // mqlAwsRdsSnapshot for the aws.rds.snapshot resource type mqlAwsRdsSnapshot struct { MqlRuntime *plugin.Runtime @@ -17997,6 +18047,8 @@ type mqlAwsRdsDbinstance struct { CreatedTime plugin.TValue[*time.Time] Port plugin.TValue[int64] Endpoint plugin.TValue[string] + MasterUsername plugin.TValue[string] + LatestRestorableTime plugin.TValue[*time.Time] } // createAwsRdsDbinstance creates a new instance of this resource @@ -18156,6 +18208,14 @@ func (c *mqlAwsRdsDbinstance) GetEndpoint() *plugin.TValue[string] { return &c.Endpoint } +func (c *mqlAwsRdsDbinstance) GetMasterUsername() *plugin.TValue[string] { + return &c.MasterUsername +} + +func (c *mqlAwsRdsDbinstance) GetLatestRestorableTime() *plugin.TValue[*time.Time] { + return &c.LatestRestorableTime +} + // mqlAwsElasticache for the aws.elasticache resource type mqlAwsElasticache struct { MqlRuntime *plugin.Runtime diff --git a/providers/aws/resources/aws.lr.manifest.yaml b/providers/aws/resources/aws.lr.manifest.yaml index b3281d4ae7..d6b2c14e21 100755 --- a/providers/aws/resources/aws.lr.manifest.yaml +++ b/providers/aws/resources/aws.lr.manifest.yaml @@ -1984,7 +1984,13 @@ resources: min_mondoo_version: 9.0.0 engineVersion: min_mondoo_version: 9.0.0 + hostedZoneId: + min_mondoo_version: 9.0.0 id: {} + latestRestorableTime: + min_mondoo_version: 9.0.0 + masterUsername: + min_mondoo_version: 9.0.0 members: {} multiAZ: min_mondoo_version: 9.0.0 @@ -2039,6 +2045,10 @@ resources: min_mondoo_version: 9.0.0 enhancedMonitoringResourceArn: {} id: {} + latestRestorableTime: + min_mondoo_version: 9.0.0 + masterUsername: + min_mondoo_version: 9.0.0 multiAZ: {} name: {} port: @@ -2548,7 +2558,7 @@ resources: scope: {} subnets: {} tags: {} - min_mondoo_version: latest + min_mondoo_version: 9.0.0 platform: name: - aws diff --git a/providers/aws/resources/aws_rds.go b/providers/aws/resources/aws_rds.go index 17445393c1..90fd743d19 100644 --- a/providers/aws/resources/aws_rds.go +++ b/providers/aws/resources/aws_rds.go @@ -98,10 +98,13 @@ func (a *mqlAwsRds) getDbInstances(conn *connection.AwsConnection) []*jobpool.Jo "dbInstanceIdentifier": llx.StringDataPtr(dbInstance.DBInstanceIdentifier), "deletionProtection": llx.BoolDataPtr(dbInstance.DeletionProtection), "enabledCloudwatchLogsExports": llx.ArrayData(stringSliceInterface, types.String), + "endpoint": llx.StringDataPtr(dbInstance.Endpoint.Address), "engine": llx.StringDataPtr(dbInstance.Engine), "engineVersion": llx.StringDataPtr(dbInstance.EngineVersion), "enhancedMonitoringResourceArn": llx.StringDataPtr(dbInstance.EnhancedMonitoringResourceArn), "id": llx.StringDataPtr(dbInstance.DBInstanceIdentifier), + "latestRestorableTime": llx.TimeDataPtr(dbInstance.LatestRestorableTime), + "masterUsername": llx.StringDataPtr(dbInstance.MasterUsername), "multiAZ": llx.BoolDataPtr(dbInstance.MultiAZ), "name": llx.StringDataPtr(dbInstance.DBName), "port": llx.IntDataDefault(dbInstance.DbInstancePort, 0), @@ -114,7 +117,6 @@ func (a *mqlAwsRds) getDbInstances(conn *connection.AwsConnection) []*jobpool.Jo "storageIops": llx.IntDataDefault(dbInstance.Iops, 0), "storageType": llx.StringDataPtr(dbInstance.StorageType), "tags": llx.MapData(rdsTagsToMap(dbInstance.TagList), types.String), - "endpoint": llx.StringDataPtr(dbInstance.Endpoint.Address), }) if err != nil { return nil, err @@ -268,7 +270,10 @@ func (a *mqlAwsRds) getDbClusters(conn *connection.AwsConnection) []*jobpool.Job "endpoint": llx.StringDataPtr(cluster.Endpoint), "engine": llx.StringDataPtr(cluster.Engine), "engineVersion": llx.StringDataPtr(cluster.EngineVersion), + "hostedZoneId": llx.StringDataPtr(cluster.HostedZoneId), "id": llx.StringDataPtr(cluster.DBClusterIdentifier), + "latestRestorableTime": llx.TimeDataPtr(cluster.LatestRestorableTime), + "masterUsername": llx.StringDataPtr(cluster.MasterUsername), "members": llx.ArrayData(mqlRdsDbInstances, types.Resource("aws.rds.dbinstance")), "multiAZ": llx.BoolDataPtr(cluster.MultiAZ), "port": llx.IntDataDefault(cluster.Port, -1),