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

Commit

Permalink
(features)The delete function for cloudwatch rum is added (#952)
Browse files Browse the repository at this point in the history
* (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 <der-eismann@users.noreply.github.com>

* Add properties

---------

Co-authored-by: Philipp Trulson <der-eismann@users.noreply.github.com>
Co-authored-by: Philipp Trulson <p.trulson@rebuy.com>
  • Loading branch information
3 people authored Aug 29, 2023
1 parent 5723826 commit 0dd135f
Showing 1 changed file with 71 additions and 0 deletions.
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
}

0 comments on commit 0dd135f

Please sign in to comment.