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

Adding support for AppRunner services #1060

Merged
merged 18 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
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
62 changes: 62 additions & 0 deletions resources/apprunner-connection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package resources

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

type AppRunnerConnection struct {
svc *apprunner.AppRunner
ConnectionArn *string
ConnectionName *string
}

func init() {
register("AppRunnerConnection", ListAppRunnerConnections)
}

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

params := &apprunner.ListConnectionsInput{}

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

for _, item := range resp.ConnectionSummaryList {
resources = append(resources, &AppRunnerConnection{
svc: svc,
ConnectionArn: item.ConnectionArn,
ConnectionName: item.ConnectionName,
})
}

if resp.NextToken == nil {
break
}

params.NextToken = resp.NextToken
}

return resources, nil
}

func (f *AppRunnerConnection) Remove() error {
_, err := f.svc.DeleteConnection(&apprunner.DeleteConnectionInput{
ConnectionArn: f.ConnectionArn,
})

return err
}

func (f *AppRunnerConnection) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("ConnectionArn", f.ConnectionArn)
properties.Set("ConnectionName", f.ConnectionName)
return properties
}
65 changes: 65 additions & 0 deletions resources/apprunner-service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package resources

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

type AppRunnerService struct {
svc *apprunner.AppRunner
ServiceArn *string
ServiceId *string
ServiceName *string
}

func init() {
register("AppRunnerService", ListAppRunnerServices)
}

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

params := &apprunner.ListServicesInput{}

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

for _, item := range resp.ServiceSummaryList {
resources = append(resources, &AppRunnerService{
svc: svc,
ServiceArn: item.ServiceArn,
ServiceId: item.ServiceId,
ServiceName: item.ServiceName,
})
}

if resp.NextToken == nil {
break
}

params.NextToken = resp.NextToken
}

return resources, nil
}

func (f *AppRunnerService) Remove() error {
_, err := f.svc.DeleteService(&apprunner.DeleteServiceInput{
ServiceArn: f.ServiceArn,
})

return err
}

func (f *AppRunnerService) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("ServiceArn", f.ServiceArn)
properties.Set("ServiceId", f.ServiceId)
properties.Set("ServiceName", f.ServiceName)
return properties
}
Loading