Skip to content

Commit 0dd135f

Browse files
(features)The delete function for cloudwatch rum is added (#952)
* (features)The delete function for cloudwatch rum is added * Update resources/cloudwatch-rum.go Change the naming convention to conform to the general style as suggested Co-authored-by: Philipp Trulson <[email protected]> * Add properties --------- Co-authored-by: Philipp Trulson <[email protected]> Co-authored-by: Philipp Trulson <[email protected]>
1 parent 5723826 commit 0dd135f

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

resources/cloudwatch-rum.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package resources
2+
3+
import (
4+
"github.com/aws/aws-sdk-go/aws/session"
5+
"github.com/aws/aws-sdk-go/service/cloudwatchrum"
6+
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
7+
)
8+
9+
type CloudWatchRumApp struct {
10+
svc *cloudwatchrum.CloudWatchRUM
11+
appmonitorname *string
12+
id *string
13+
state *string
14+
}
15+
16+
func init() {
17+
register("CloudWatchRUMApp", ListCloudWatchRumApp)
18+
}
19+
20+
func ListCloudWatchRumApp(sess *session.Session) ([]Resource, error) {
21+
svc := cloudwatchrum.New(sess)
22+
resources := []Resource{}
23+
24+
params := &cloudwatchrum.ListAppMonitorsInput{}
25+
26+
for {
27+
output, err := svc.ListAppMonitors(params)
28+
if err != nil {
29+
return nil, err
30+
}
31+
32+
for _, appEntry := range output.AppMonitorSummaries {
33+
resources = append(resources, &CloudWatchRumApp{
34+
svc: svc,
35+
appmonitorname: appEntry.Name,
36+
id: appEntry.Id,
37+
state: appEntry.State,
38+
})
39+
}
40+
41+
if output.NextToken == nil {
42+
break
43+
}
44+
45+
params.NextToken = output.NextToken
46+
}
47+
48+
return resources, nil
49+
}
50+
51+
func (f *CloudWatchRumApp) Remove() error {
52+
53+
_, err := f.svc.DeleteAppMonitor(&cloudwatchrum.DeleteAppMonitorInput{
54+
Name: f.appmonitorname,
55+
})
56+
57+
return err
58+
}
59+
60+
func (f *CloudWatchRumApp) Properties() types.Properties {
61+
properties := types.NewProperties()
62+
properties.Set("Name", *f.appmonitorname)
63+
properties.Set("ID", *f.id)
64+
properties.Set("State", *f.state)
65+
66+
return properties
67+
}
68+
69+
func (f *CloudWatchRumApp) String() string {
70+
return *f.appmonitorname
71+
}

0 commit comments

Comments
 (0)