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

Commit

Permalink
Register MSK service
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermo-menjivar committed Apr 29, 2019
1 parent 6b3bdb7 commit 64c6d99
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ resource-types:
- Route53HostedZone
- EC2Instance
- CloudFormationStack
- MSKCluster

accounts:
555133742:
Expand Down
61 changes: 61 additions & 0 deletions resources/msk-cluster.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/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
}

0 comments on commit 64c6d99

Please sign in to comment.