From 2fc993b765b70cd232b48d9f68046763e9677ab7 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 5 Jan 2024 01:23:53 -0800 Subject: [PATCH] Add port and endpoint to aws.rds.dbinstance (#2946) A few more useful items to align with the dbcluster resource Signed-off-by: Tim Smith --- providers/aws/resources/aws.lr | 4 ++++ providers/aws/resources/aws.lr.go | 24 ++++++++++++++++++++ providers/aws/resources/aws.lr.manifest.yaml | 4 ++++ providers/aws/resources/aws_rds.go | 2 ++ 4 files changed, 34 insertions(+) diff --git a/providers/aws/resources/aws.lr b/providers/aws/resources/aws.lr index 02b3ac8663..725ba89254 100644 --- a/providers/aws/resources/aws.lr +++ b/providers/aws/resources/aws.lr @@ -1892,6 +1892,10 @@ private aws.rds.dbinstance @defaults("id region engine engineVersion") { autoMinorVersionUpgrade bool // The creation date of the RDS instance createdTime time + // The port that the DB instance listens on. If the DB instance is part of a DB cluster, this can be a different port than the DB cluster port. + port int + // The connection endpoint for the DB instance + endpoint string } // Amazon ElastiCache diff --git a/providers/aws/resources/aws.lr.go b/providers/aws/resources/aws.lr.go index 9e3d54fa8b..9cd79185c5 100644 --- a/providers/aws/resources/aws.lr.go +++ b/providers/aws/resources/aws.lr.go @@ -2802,6 +2802,12 @@ var getDataFields = map[string]func(r plugin.Resource) *plugin.DataRes{ "aws.rds.dbinstance.createdTime": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlAwsRdsDbinstance).GetCreatedTime()).ToDataRes(types.Time) }, + "aws.rds.dbinstance.port": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlAwsRdsDbinstance).GetPort()).ToDataRes(types.Int) + }, + "aws.rds.dbinstance.endpoint": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlAwsRdsDbinstance).GetEndpoint()).ToDataRes(types.String) + }, "aws.elasticache.clusters": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlAwsElasticache).GetClusters()).ToDataRes(types.Array(types.Dict)) }, @@ -6885,6 +6891,14 @@ var setDataFields = map[string]func(r plugin.Resource, v *llx.RawData) bool { r.(*mqlAwsRdsDbinstance).CreatedTime, ok = plugin.RawToTValue[*time.Time](v.Value, v.Error) return }, + "aws.rds.dbinstance.port": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlAwsRdsDbinstance).Port, ok = plugin.RawToTValue[int64](v.Value, v.Error) + return + }, + "aws.rds.dbinstance.endpoint": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlAwsRdsDbinstance).Endpoint, ok = plugin.RawToTValue[string](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 @@ -17757,6 +17771,8 @@ type mqlAwsRdsDbinstance struct { Status plugin.TValue[string] AutoMinorVersionUpgrade plugin.TValue[bool] CreatedTime plugin.TValue[*time.Time] + Port plugin.TValue[int64] + Endpoint plugin.TValue[string] } // createAwsRdsDbinstance creates a new instance of this resource @@ -17908,6 +17924,14 @@ func (c *mqlAwsRdsDbinstance) GetCreatedTime() *plugin.TValue[*time.Time] { return &c.CreatedTime } +func (c *mqlAwsRdsDbinstance) GetPort() *plugin.TValue[int64] { + return &c.Port +} + +func (c *mqlAwsRdsDbinstance) GetEndpoint() *plugin.TValue[string] { + return &c.Endpoint +} + // 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 3375bafc6c..185548aa49 100755 --- a/providers/aws/resources/aws.lr.manifest.yaml +++ b/providers/aws/resources/aws.lr.manifest.yaml @@ -1987,6 +1987,8 @@ resources: min_mondoo_version: 5.19.1 deletionProtection: {} enabledCloudwatchLogsExports: {} + endpoint: + min_mondoo_version: 9.0.0 engine: min_mondoo_version: 5.19.1 engineVersion: @@ -1995,6 +1997,8 @@ resources: id: {} multiAZ: {} name: {} + port: + min_mondoo_version: 9.0.0 publiclyAccessible: {} region: {} securityGroups: diff --git a/providers/aws/resources/aws_rds.go b/providers/aws/resources/aws_rds.go index 5fa6bbb043..9375498fbf 100644 --- a/providers/aws/resources/aws_rds.go +++ b/providers/aws/resources/aws_rds.go @@ -104,6 +104,7 @@ func (a *mqlAwsRds) getDbInstances(conn *connection.AwsConnection) []*jobpool.Jo "id": llx.StringDataPtr(dbInstance.DBInstanceIdentifier), "multiAZ": llx.BoolDataPtr(dbInstance.MultiAZ), "name": llx.StringDataPtr(dbInstance.DBName), + "port": llx.IntData(convert.ToInt64From32(dbInstance.DbInstancePort)), "publiclyAccessible": llx.BoolDataPtr(dbInstance.PubliclyAccessible), "region": llx.StringData(regionVal), "securityGroups": llx.ArrayData(sgs, types.Resource("aws.ec2.securitygroup")), @@ -113,6 +114,7 @@ func (a *mqlAwsRds) getDbInstances(conn *connection.AwsConnection) []*jobpool.Jo "storageIops": llx.IntData(convert.ToInt64From32(dbInstance.Iops)), "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