From b1988f6b5dfd0070b028a2b2f53f09bd86632c0e Mon Sep 17 00:00:00 2001 From: Stefan Horning Date: Wed, 17 Feb 2021 10:22:32 +0100 Subject: [PATCH 1/3] Allow a bunch of elasticache actions for CI testing elasticache module --- aws/policy/data-services.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/aws/policy/data-services.yaml b/aws/policy/data-services.yaml index cb9ea489..383a28b0 100644 --- a/aws/policy/data-services.yaml +++ b/aws/policy/data-services.yaml @@ -30,6 +30,21 @@ Statement: - dynamodb:DeleteTable - dynamodb:UpdateTable - dynamodb:TagResource + - elasticache:AddTagsToResource + - elasticache:CreateCacheSecurityGroup + - elasticache:CreateCacheSubnetGroup + - elasticache:DeleteCacheCluster + - elasticache:DeleteCacheSecurityGroup + - elasticache:DeleteCacheSubnetGroup + - elasticache:DescribeCacheClusters + - elasticache:DescribeCacheEngineVersions + - elasticache:DescribeCacheParameterGroups + - elasticache:DescribeCacheParameters + - elasticache:DescribeCacheSecurityGroups + - elasticache:DescribeCacheSubnetGroups + - elasticache:DescribeEngineDefaultParameters + - elasticache:DescribeUpdateActions + - elasticache:RemoveTagsFromResource - glacier:ListVaults - glacier:CreateVault - glacier:DeleteVault @@ -58,6 +73,10 @@ Statement: Resource: - 'arn:aws:dms:{{ aws_region }}:{{ aws_account_id }}:subgrp:*' - 'arn:aws:dynamodb:{{ aws_region }}:{{ aws_account_id }}:table/*' + - 'arn:aws:elasticache:{{ aws_region }}:{{ aws_account_id }}:cluster:*' + - 'arn:aws:elasticache:{{ aws_region }}:{{ aws_account_id }}:subnetgroup:*' + - 'arn:aws:elasticache:{{ aws_region }}:{{ aws_account_id }}:parametergroup:*' + - 'arn:aws:elasticache:{{ aws_region }}:{{ aws_account_id }}:securitygroup:*' - 'arn:aws:glacier:{{ aws_region }}:{{ aws_account_id }}:vaults/*' - 'arn:aws:redshift:{{ aws_region }}:{{ aws_account_id }}:cluster:*' - 'arn:aws:rds:{{ aws_region }}:{{ aws_account_id }}:subgrp:*' @@ -67,7 +86,9 @@ Statement: Effect: Allow Action: - rds:CreateDBCluster + - elasticache:CreateCacheCluster - redshift:CreateCluster Resource: - 'arn:aws:rds:{{ aws_region }}:{{ aws_account_id }}:cluster:*' + - 'arn:aws:elasticache:{{ aws_region }}:{{ aws_account_id }}:cluster:*' - 'arn:aws:redshift:{{ aws_region }}:{{ aws_account_id }}:cluster:*' From ef77375e9bc306b74bfe0dc0089111779b053fe0 Mon Sep 17 00:00:00 2001 From: Stefan Horning Date: Fri, 19 Feb 2021 11:20:18 +0100 Subject: [PATCH 2/3] Add Elasticache class to data services --- aws/terminator/data_services.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/aws/terminator/data_services.py b/aws/terminator/data_services.py index 992f05ec..c98c3e0f 100644 --- a/aws/terminator/data_services.py +++ b/aws/terminator/data_services.py @@ -20,6 +20,26 @@ def name(self): def terminate(self): self.client.delete_replication_subnet_group(ReplicationSubnetGroupIdentifier=self.id) +class Elasticache(Terminator): + @staticmethod + def create(credentials): + return Terminator._create(credentials, Elasticache, 'elasticache', lambda client: client.describe_cache_clusters()['CacheClusters']) + + @property + def name(self): + # Name is used like an ID + return self.instance['CacheClusterId'] + + @property + def id(self): + return self.instance['CacheClusterId'] + + @property + def created_time(self): + return self.instance['CacheClusterCreateTime'] + + def terminate(self): + self.client.delete_cache_cluster(CacheClusterId=self.id) class GlueConnection(Terminator): @staticmethod From f43266702dff434ff059acd296a4ac64e11fe75e Mon Sep 17 00:00:00 2001 From: Stefan Horning Date: Fri, 19 Feb 2021 11:26:54 +0100 Subject: [PATCH 3/3] Fixed formatting --- aws/terminator/data_services.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aws/terminator/data_services.py b/aws/terminator/data_services.py index c98c3e0f..2a67eb53 100644 --- a/aws/terminator/data_services.py +++ b/aws/terminator/data_services.py @@ -20,6 +20,7 @@ def name(self): def terminate(self): self.client.delete_replication_subnet_group(ReplicationSubnetGroupIdentifier=self.id) + class Elasticache(Terminator): @staticmethod def create(credentials): @@ -41,6 +42,7 @@ def created_time(self): def terminate(self): self.client.delete_cache_cluster(CacheClusterId=self.id) + class GlueConnection(Terminator): @staticmethod def create(credentials):