This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 725
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Sagemaker NotebookInstanceLifecycleConfigs (#558)
* add Sagemaker NotebookInstanceLifecycleConfigs https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ListNotebookInstanceLifecycleConfigs.html * add properties * shorten property name * Update resources/sagemaker-notebookinstancelifecycleconfigs.go Co-authored-by: Sven Walter <[email protected]>
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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/sagemaker" | ||
"github.com/rebuy-de/aws-nuke/pkg/types" | ||
) | ||
|
||
type SageMakerNotebookInstanceLifecycleConfig struct { | ||
svc *sagemaker.SageMaker | ||
Name *string | ||
} | ||
|
||
func init() { | ||
register("SageMakerNotebookInstanceLifecycleConfig", ListSageMakerNotebookInstanceLifecycleConfigs) | ||
} | ||
|
||
func ListSageMakerNotebookInstanceLifecycleConfigs(sess *session.Session) ([]Resource, error) { | ||
svc := sagemaker.New(sess) | ||
resources := []Resource{} | ||
|
||
params := &sagemaker.ListNotebookInstanceLifecycleConfigsInput{ | ||
MaxResults: aws.Int64(30), | ||
} | ||
|
||
for { | ||
resp, err := svc.ListNotebookInstanceLifecycleConfigs(params) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, lifecycleConfig := range resp.NotebookInstanceLifecycleConfigs { | ||
resources = append(resources, &SageMakerNotebookInstanceLifecycleConfig{ | ||
svc: svc, | ||
Name: lifecycleConfig.NotebookInstanceLifecycleConfigName, | ||
}) | ||
} | ||
|
||
if resp.NextToken == nil { | ||
break | ||
} | ||
|
||
params.NextToken = resp.NextToken | ||
} | ||
|
||
return resources, nil | ||
} | ||
|
||
func (f *SageMakerNotebookInstanceLifecycleConfig) Remove() error { | ||
|
||
_, err := f.svc.DeleteNotebookInstanceLifecycleConfig(&sagemaker.DeleteNotebookInstanceLifecycleConfigInput{ | ||
NotebookInstanceLifecycleConfigName: f.Name, | ||
}) | ||
|
||
return err | ||
} | ||
|
||
func (f *SageMakerNotebookInstanceLifecycleConfig) String() string { | ||
return *f.Name | ||
} | ||
|
||
func (f *SageMakerNotebookInstanceLifecycleConfig) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties. | ||
Set("Name", f.Name) | ||
return properties | ||
} |