Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

(features)The delete function for cloudwatch rum is added #952

Merged
merged 4 commits into from
Aug 29, 2023
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
71 changes: 71 additions & 0 deletions resources/cloudwatch-rum.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package resources

import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/cloudwatchrum"
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
)

type CloudWatchRumApp struct {
svc *cloudwatchrum.CloudWatchRUM
appmonitorname *string
id *string
state *string
}

func init() {
register("CloudWatchRUMApp", ListCloudWatchRumApp)
}

func ListCloudWatchRumApp(sess *session.Session) ([]Resource, error) {
svc := cloudwatchrum.New(sess)
resources := []Resource{}

params := &cloudwatchrum.ListAppMonitorsInput{}

for {
output, err := svc.ListAppMonitors(params)
if err != nil {
return nil, err
}

for _, appEntry := range output.AppMonitorSummaries {
resources = append(resources, &CloudWatchRumApp{
svc: svc,
appmonitorname: appEntry.Name,
id: appEntry.Id,
state: appEntry.State,
})
}

if output.NextToken == nil {
break
}

params.NextToken = output.NextToken
}

return resources, nil
}

func (f *CloudWatchRumApp) Remove() error {

_, err := f.svc.DeleteAppMonitor(&cloudwatchrum.DeleteAppMonitorInput{
Name: f.appmonitorname,
})

return err
}

func (f *CloudWatchRumApp) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("Name", *f.appmonitorname)
properties.Set("ID", *f.id)
properties.Set("State", *f.state)

return properties
}

func (f *CloudWatchRumApp) String() string {
return *f.appmonitorname
}
Loading