@@ -164,7 +164,7 @@ func processInstances(ctx context.Context, rdsClient *rds.Client, region string)
164164 }
165165
166166 for _ , instance := range resp .DBInstances {
167- resource , err := processInstance (ctx , & instance , region )
167+ resource , err := processInstance (ctx , & instance , region , rdsClient )
168168 if err != nil {
169169 log .Error ("Failed to process RDS instance" , "identifier" , * instance .DBInstanceIdentifier , "error" , err )
170170 continue
@@ -182,7 +182,7 @@ func processInstances(ctx context.Context, rdsClient *rds.Client, region string)
182182 return resources , nil
183183}
184184
185- func processInstance (_ context.Context , instance * types.DBInstance , region string ) (api.AgentResource , error ) {
185+ func processInstance (ctx context.Context , instance * types.DBInstance , region string , rdsClient * rds. Client ) (api.AgentResource , error ) {
186186 // Get default port based on engine
187187 port := int32 (5432 ) // Default to PostgreSQL port
188188 if instance .Endpoint != nil && instance .Endpoint .Port != nil && * instance .Endpoint .Port != 0 {
@@ -209,6 +209,15 @@ func processInstance(_ context.Context, instance *types.DBInstance, region strin
209209
210210 metadata := buildInstanceMetadata (instance , region , host , int (port ), consoleUrl )
211211
212+ // Add parameter group details if available
213+ if len (instance .DBParameterGroups ) > 0 {
214+ for _ , pg := range instance .DBParameterGroups {
215+ if pg .DBParameterGroupName != nil {
216+ fetchParameterGroupDetails (ctx , rdsClient , * pg .DBParameterGroupName , metadata )
217+ }
218+ }
219+ }
220+
212221 return api.AgentResource {
213222 Version : "ctrlplane.dev/database/v1" ,
214223 Kind : "AWSRelationalDatabaseService" ,
@@ -462,6 +471,44 @@ var relationshipRules = []api.CreateResourceRelationshipRule{
462471 },
463472}
464473
474+ // fetchParameterGroupDetails retrieves parameters from a parameter group and adds them to metadata
475+ func fetchParameterGroupDetails (ctx context.Context , rdsClient * rds.Client , parameterGroupName string , metadata map [string ]string ) {
476+ metadata ["database/parameter-group" ] = parameterGroupName
477+
478+ // Get the parameters for this parameter group
479+ var marker * string
480+ paramCount := 0
481+
482+ for {
483+ resp , err := rdsClient .DescribeDBParameters (ctx , & rds.DescribeDBParametersInput {
484+ DBParameterGroupName : & parameterGroupName ,
485+ Marker : marker ,
486+ })
487+ if err != nil {
488+ log .Error ("Failed to get parameter group details" , "parameter_group" , parameterGroupName , "error" , err )
489+ return
490+ }
491+
492+ for _ , param := range resp .Parameters {
493+ if param .ParameterName != nil && param .ParameterValue != nil {
494+ paramKey := fmt .Sprintf ("database/parameter/%s" , * param .ParameterName )
495+ metadata [paramKey ] = * param .ParameterValue
496+ paramCount ++
497+ }
498+ }
499+
500+ if resp .Marker == nil {
501+ break
502+ }
503+ marker = resp .Marker
504+ }
505+
506+ // Add a count of how many parameters were added
507+ if paramCount > 0 {
508+ metadata ["database/parameter-count" ] = strconv .Itoa (paramCount )
509+ }
510+ }
511+
465512// upsertToCtrlplane handles upserting resources to Ctrlplane
466513func upsertToCtrlplane (ctx context.Context , resources []api.AgentResource , region , name * string ) error {
467514 if * name == "" {
0 commit comments