Skip to content

Commit

Permalink
Merge pull request #143 from oukooveu/master
Browse files Browse the repository at this point in the history
Support for AWS MSK services has been added
  • Loading branch information
jillr authored May 4, 2021
2 parents 6e108f0 + 98df424 commit 3fe641b
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
40 changes: 40 additions & 0 deletions aws/policy/data-services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,47 @@ Statement:
- iam:CreateServiceLinkedRole
Resource:
- 'arn:aws:iam::{{ aws_account_id }}:role/aws-service-role/elasticache.amazonaws.com/AWSServiceRoleForElastiCache'
- 'arn:aws:iam::{{ aws_account_id }}:role/aws-service-role/kafka.amazonaws.com/AWSServiceRoleForKafka'
Condition:
ForAnyValue:StringEquals:
iam:AWSServiceName:
- 'elasticache.amazonaws.com'
- 'kafka.amazonaws.com'
- Sid: KafkaConfiguration
Effect: Allow
Action:
- kafka:CreateConfiguration
- kafka:DescribeConfigurationRevision
- kafka:DeleteConfiguration
- kafka:ListConfigurationRevisions
- kafka:DescribeConfiguration
- kafka:ListConfigurations
- kafka:UpdateConfiguration
Resource: "*"
- Sid: KafkaCluster
Effect: Allow
Action:
- kafka:UpdateClusterKafkaVersion
- kafka:TagResource
- kafka:UpdateBrokerCount
- kafka:CreateCluster
- kafka:ListTagsForResource
- kafka:GetCompatibleKafkaVersions
- kafka:UpdateClusterConfiguration
- kafka:ListClusters
- kafka:ListScramSecrets
- kafka:DescribeCluster
- kafka:ListKafkaVersions
- kafka:GetBootstrapBrokers
- kafka:ListConfigurations
- kafka:UpdateBrokerStorage
- kafka:RebootBroker
- kafka:DescribeClusterOperation
- kafka:UpdateMonitoring
- kafka:ListConfigurationRevisions
- kafka:ListNodes
- kafka:DeleteCluster
- kafka:UpdateBrokerType
- kafka:UntagResource
- kafka:ListClusterOperations
Resource: "*"
52 changes: 52 additions & 0 deletions aws/terminator/data_services.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import datetime

from . import DbTerminator, Terminator, get_tag_dict_from_tag_list


Expand Down Expand Up @@ -158,3 +160,53 @@ def created_time(self):

def terminate(self):
self.client.delete_cluster(ClusterIdentifier=self.id, SkipFinalClusterSnapshot=True)


class KafkaConfiguration(Terminator):
@staticmethod
def create(credentials):
return Terminator._create(credentials, KafkaConfiguration, 'kafka', lambda client: client.list_configurations()['Configurations'])

@property
def id(self):
return self.instance['Arn']

@property
def name(self):
return self.instance['Name']

@property
def created_time(self):
return self.instance['CreationTime']

@property
def age_limit(self):
return datetime.timedelta(minutes=60)

def terminate(self):
self.client.delete_configuration(Arn=self.id)


class KafkaCluster(Terminator):
@staticmethod
def create(credentials):
return Terminator._create(credentials, KafkaCluster, 'kafka', lambda client: client.list_clusters()['ClusterInfoList'])

@property
def id(self):
return self.instance['ClusterArn']

@property
def name(self):
return self.instance['ClusterName']

@property
def created_time(self):
return self.instance['CreationTime']

@property
def age_limit(self):
return datetime.timedelta(minutes=60)

def terminate(self):
self.client.delete_cluster(ClusterArn=self.id)

0 comments on commit 3fe641b

Please sign in to comment.