Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

fix: Config Status Recorder #406

Merged
merged 4 commits into from
Jan 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions resources/services/config/configuration_recorders.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func ConfigConfigurationRecorders() *schema.Table {
// ====================================================================================================================
func fetchConfigConfigurationRecorders(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
c := meta.(*client.Client)

resp, err := c.Services().ConfigService.DescribeConfigurationRecorders(ctx, &configservice.DescribeConfigurationRecordersInput{}, func(options *configservice.Options) {
options.Region = c.Region
})
Expand All @@ -134,23 +135,31 @@ func fetchConfigConfigurationRecorders(ctx context.Context, meta schema.ClientMe
return err
}
for _, configurationRecorder := range resp.ConfigurationRecorders {
if configurationRecorder.Name == nil {
continue
}
var configurationRecorderStatus types.ConfigurationRecorderStatus
for _, s := range status.ConfigurationRecordersStatus {
if s.Name == configurationRecorder.Name {
if s.Name == nil {
continue
}
if *s.Name == *configurationRecorder.Name {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a nil check

configurationRecorderStatus = s
res <- configurationRecorderWrapper{
ConfigurationRecorder: configurationRecorder,
StatusLastErrorCode: configurationRecorderStatus.LastErrorCode,
StatusLastErrorMessage: configurationRecorderStatus.LastErrorMessage,
StatusLastStartTime: configurationRecorderStatus.LastStartTime,
StatusLastStatus: configurationRecorderStatus.LastStatus,
StatusLastStatusChangeTime: configurationRecorderStatus.LastStatusChangeTime,
StatusLastStopTime: configurationRecorderStatus.LastStopTime,
StatusRecording: configurationRecorderStatus.Recording,
}

break
}
}
res <- configurationRecorderWrapper{
ConfigurationRecorder: configurationRecorder,
StatusLastErrorCode: configurationRecorderStatus.LastErrorCode,
StatusLastErrorMessage: configurationRecorderStatus.LastErrorMessage,
StatusLastStartTime: configurationRecorderStatus.LastStartTime,
StatusLastStatus: configurationRecorderStatus.LastStatus,
StatusLastStatusChangeTime: configurationRecorderStatus.LastStatusChangeTime,
StatusLastStopTime: configurationRecorderStatus.LastStopTime,
StatusRecording: configurationRecorderStatus.Recording,
}

}
return nil
}
Expand Down