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

Commit

Permalink
Add support for managed grafana (#859)
Browse files Browse the repository at this point in the history
  • Loading branch information
avrittrohwer authored Oct 11, 2022
1 parent 27dc2af commit 8e23ba5
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions resources/managedgrafana-workspaces.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package resources

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

type AMGWorkspace struct {
svc *managedgrafana.ManagedGrafana
id *string
name *string
}

func init() {
register("AMGWorkspace", ListAMGWorkspaces)
}

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

var amgWorkspaces []*managedgrafana.WorkspaceSummary
err := svc.ListWorkspacesPages(
&managedgrafana.ListWorkspacesInput{},
func(page *managedgrafana.ListWorkspacesOutput, lastPage bool) bool {
amgWorkspaces = append(amgWorkspaces, page.Workspaces...)
return true
},
)
if err != nil {
return nil, err
}

for _, ws := range amgWorkspaces {
resources = append(resources, &AMGWorkspace{
svc: svc,
id: ws.Id,
name: ws.Name,
})
}

return resources, nil
}

func (f *AMGWorkspace) Remove() error {
_, err := f.svc.DeleteWorkspace(&managedgrafana.DeleteWorkspaceInput{
WorkspaceId: f.id,
})

return err
}

func (f *AMGWorkspace) Properties() types.Properties {
properties := types.NewProperties()
properties.
Set("WorkspaceId", f.id).
Set("WorkspaceName", f.name)

return properties
}

0 comments on commit 8e23ba5

Please sign in to comment.