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.
- Loading branch information
1 parent
6b3bdb7
commit 64c6d99
Showing
2 changed files
with
62 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
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,61 @@ | ||
package resources | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/kafka" | ||
"github.com/rebuy-de/aws-nuke/pkg/types" | ||
) | ||
|
||
type MSKCluster struct { | ||
svc *kafka.Kafka | ||
arn string | ||
name string | ||
} | ||
|
||
func init() { | ||
register("MSKCluster", ListMSKCluster) | ||
} | ||
|
||
func ListMSKCluster(sess *session.Session) ([]Resource, error) { | ||
svc := kafka.New(sess) | ||
params := &kafka.ListClustersInput{} | ||
resp, err := svc.ListClusters(params) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
resources := make([]Resource, 0) | ||
for _, cluster := range resp.ClusterInfoList { | ||
resources = append(resources, &MSKCluster{ | ||
svc: svc, | ||
arn: *cluster.ClusterArn, | ||
name: *cluster.ClusterName, | ||
}) | ||
|
||
} | ||
return resources, nil | ||
} | ||
|
||
func (m *MSKCluster) Remove() error { | ||
params := &kafka.DeleteClusterInput{ | ||
ClusterArn: &m.arn, | ||
} | ||
|
||
_, err := m.svc.DeleteCluster(params) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func (m *MSKCluster) String() string { | ||
return m.arn | ||
} | ||
|
||
func (m *MSKCluster) Properties() types.Properties { | ||
properties := types.NewProperties() | ||
properties.Set("ARN", m.arn) | ||
properties.Set("NAME", m.name) | ||
|
||
return properties | ||
} |