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

Support Amplify apps #1148

Closed
wants to merge 2 commits into from
Closed
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
75 changes: 75 additions & 0 deletions resources/amplify-apps.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package resources

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

type AmplifyApp struct {
svc *amplify.Amplify
appID *string
name *string
tags map[string]*string
}

func init() {
register("AmplifyApp", ListAmplifyApps)
}

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

params := &amplify.ListAppsInput{
MaxResults: aws.Int64(100),
}

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

for _, item := range output.Apps {
resources = append(resources, &AmplifyApp{
svc: svc,
appID: item.AppId,
name: item.Name,
tags: item.Tags,
})
}

if output.NextToken == nil {
break
}

params.NextToken = output.NextToken
}

return resources, nil
}

func (f *AmplifyApp) Remove() error {
_, err := f.svc.DeleteApp(&amplify.DeleteAppInput{
AppId: f.appID,
})

return err
}

func (f *AmplifyApp) String() string {
return *f.appID
}

func (f *AmplifyApp) Properties() types.Properties {
properties := types.NewProperties()
for key, tag := range f.tags {
properties.SetTag(&key, tag)
}
properties.
Set("AppID", f.appID).
Set("Name", f.name)
return properties
}