-
Notifications
You must be signed in to change notification settings - Fork 720
/
configservice-configurationrecorders.go
48 lines (37 loc) · 1.24 KB
/
configservice-configurationrecorders.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package resources
import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/configservice"
)
type ConfigServiceConfigurationRecorder struct {
svc *configservice.ConfigService
configurationRecorderName *string
}
func init() {
register("ConfigServiceConfigurationRecorder", ListConfigServiceConfigurationRecorders)
}
func ListConfigServiceConfigurationRecorders(sess *session.Session) ([]Resource, error) {
svc := configservice.New(sess)
params := &configservice.DescribeConfigurationRecordersInput{}
resp, err := svc.DescribeConfigurationRecorders(params)
if err != nil {
return nil, err
}
resources := make([]Resource, 0)
for _, configurationRecorder := range resp.ConfigurationRecorders {
resources = append(resources, &ConfigServiceConfigurationRecorder{
svc: svc,
configurationRecorderName: configurationRecorder.Name,
})
}
return resources, nil
}
func (f *ConfigServiceConfigurationRecorder) Remove() error {
_, err := f.svc.DeleteConfigurationRecorder(&configservice.DeleteConfigurationRecorderInput{
ConfigurationRecorderName: f.configurationRecorderName,
})
return err
}
func (f *ConfigServiceConfigurationRecorder) String() string {
return *f.configurationRecorderName
}