diff --git a/c7n/resources/kafka.py b/c7n/resources/kafka.py index 41a632b8041..ad344d1550b 100644 --- a/c7n/resources/kafka.py +++ b/c7n/resources/kafka.py @@ -14,6 +14,13 @@ class DescribeKafka(DescribeSource): def augment(self, resources): for r in resources: + # preserve backwards compat with extant list_clsuters api + if 'Provisioned' in r: + for k, v in r['Provisioned'].items(): + # dont overwrite + if k in r: + continue + r[k] = v if 'Tags' not in r: continue tags = [] @@ -28,7 +35,7 @@ class Kafka(QueryResourceManager): class resource_type(TypeInfo): service = 'kafka' - enum_spec = ('list_clusters', 'ClusterInfoList', None) + enum_spec = ('list_clusters_v2', 'ClusterInfoList', None) arn = id = 'ClusterArn' name = 'ClusterName' date = 'CreationTime' @@ -50,9 +57,37 @@ class KafkaSGFilter(SecurityGroupFilter): @Kafka.filter_registry.register('subnet') -class KafkaSubnetFilter(SubnetFilter): +class KafkaCompoundSubnetFilter(SubnetFilter): - RelatedIdsExpression = "BrokerNodeGroupInfo.ClientSubnets[]" + RelatedIdsExpression = "compound" + + def process(self, resources, event=None): + # kafka v2 has both serverless and provisioned resources which have two different + # locations for their subnet info + + class ProvisionedSubnetFilter(SubnetFilter): + RelatedIdsExpression = "Provisioned.BrokerNodeGroupInfo.ClientSubnets[]" + + class ServerlessSubnetFilter(SubnetFilter): + RelatedIdsExpression = "Serverless.VpcConfigs[].SubnetIds[]" + + p = [] + s = [] + + for r in resources: + if r['ClusterType'] == 'PROVISIONED': + p.append(r) + if r['ClusterType'] == 'SERVERLESS': + s.append(r) + + result = [] + for filtered, fil in ((p, ProvisionedSubnetFilter), (s, ServerlessSubnetFilter), ): + f = fil(self.data, self.manager) + # necessary to validate otherwise the filter wont work + f.validate() + result.extend(f.process(filtered, event)) + + return result @Kafka.filter_registry.register('kms-key') @@ -74,7 +109,7 @@ class KafkaKmsFilter(KmsRelatedFilter): key: c7n:AliasName value: alias/aws/kafka """ - RelatedIdsExpression = 'EncryptionInfo.EncryptionAtRest.DataVolumeKMSKeyId' + RelatedIdsExpression = 'Provisioned.EncryptionInfo.EncryptionAtRest.DataVolumeKMSKeyId' @Kafka.action_registry.register('set-monitoring') diff --git a/tests/data/iam-actions.json b/tests/data/iam-actions.json index 3d1462e4eae..999d18d829a 100644 --- a/tests/data/iam-actions.json +++ b/tests/data/iam-actions.json @@ -6082,6 +6082,7 @@ "GetCompatibleKafkaVersions", "ListClusterOperations", "ListClusters", + "ListClustersV2", "ListConfigurationRevisions", "ListConfigurations", "ListKafkaVersions", @@ -11166,4 +11167,4 @@ "UpdateGroup", "UpdateSamplingRule" ] -} \ No newline at end of file +} diff --git a/tests/data/placebo/test_kafka_cluster_kms_filter/kafka.ListClustersV2_1.json b/tests/data/placebo/test_kafka_cluster_kms_filter/kafka.ListClustersV2_1.json new file mode 100644 index 00000000000..e58d1bb8160 --- /dev/null +++ b/tests/data/placebo/test_kafka_cluster_kms_filter/kafka.ListClustersV2_1.json @@ -0,0 +1,95 @@ +{ + "status_code": 200, + "data": { + "ResponseMetadata": {}, + "ClusterInfoList": [ + { + "ClusterType": "PROVISIONED", + "ClusterArn": "arn:aws:kafka:ap-northeast-2:644160558196:cluster/demo-cluster-1/a4128f17-d0a5-4b03-b858-ea13108e7286-4", + "ClusterName": "demo-cluster-1", + "CreationTime": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 9, + "hour": 23, + "minute": 13, + "second": 39, + "microsecond": 670000 + }, + "CurrentVersion": "K3P5ROKL5A1OLE", + "State": "ACTIVE", + "Tags": { + "App": "Custodian" + }, + "Provisioned": { + "BrokerNodeGroupInfo": { + "BrokerAZDistribution": "DEFAULT", + "ClientSubnets": [ + "subnet-04f91d4b", + "subnet-efc87884", + "subnet-2418755f" + ], + "InstanceType": "kafka.m5.large", + "SecurityGroups": [ + "sg-bd0718c6" + ], + "StorageInfo": { + "EbsStorageInfo": { + "VolumeSize": 100 + } + }, + "ConnectivityInfo": { + "PublicAccess": { + "Type": "DISABLED" + } + } + }, + "CurrentBrokerSoftwareInfo": { + "KafkaVersion": "2.8.1" + }, + "ClientAuthentication": { + "Sasl": { + "Scram": { + "Enabled": false + }, + "Iam": { + "Enabled": true + } + }, + "Tls": { + "CertificateAuthorityArnList": [], + "Enabled": false + }, + "Unauthenticated": { + "Enabled": false + } + }, + "EncryptionInfo": { + "EncryptionAtRest": { + "DataVolumeKMSKeyId": "arn:aws:kms:ap-northeast-2:644160558196:key/d0e564f4-ec4c-43bd-b379-a22f92253dbe" + }, + "EncryptionInTransit": { + "ClientBroker": "TLS", + "InCluster": true + } + }, + "EnhancedMonitoring": "DEFAULT", + "OpenMonitoring": { + "Prometheus": { + "JmxExporter": { + "EnabledInBroker": false + }, + "NodeExporter": { + "EnabledInBroker": false + } + } + }, + "NumberOfBrokerNodes": 3, + "ZookeeperConnectString": "z-3.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181,z-1.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181,z-2.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181", + "ZookeeperConnectStringTls": "z-3.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182,z-1.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182,z-2.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182" + } + } + ] + } +} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_cluster_kms_filter/kafka.ListClusters_1.json b/tests/data/placebo/test_kafka_cluster_kms_filter/kafka.ListClusters_1.json deleted file mode 100644 index a3caf760b14..00000000000 --- a/tests/data/placebo/test_kafka_cluster_kms_filter/kafka.ListClusters_1.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "status_code": 200, - "data": { - "ResponseMetadata": {}, - "ClusterInfoList": [ - { - "BrokerNodeGroupInfo": { - "BrokerAZDistribution": "DEFAULT", - "ClientSubnets": [ - "subnet-3a334610", - "subnet-efbcccb7" - ], - "InstanceType": "kafka.t3.small", - "SecurityGroups": [ - "sg-6c7fa917" - ], - "StorageInfo": { - "EbsStorageInfo": { - "VolumeSize": 2 - } - } - }, - "ClusterArn": "arn:aws:kafka:us-east-1:644160558196:cluster/demo-cluster-1/6a7ad979-bce8-4a7f-9e34-fff3a52125ba-14", - "ClusterName": "demo-cluster-1", - "CreationTime": { - "__class__": "datetime", - "year": 2021, - "month": 6, - "day": 24, - "hour": 15, - "minute": 53, - "second": 46, - "microsecond": 511000 - }, - "CurrentBrokerSoftwareInfo": { - "KafkaVersion": "2.6.1" - }, - "CurrentVersion": "K3P5ROKL5A1OLE", - "EncryptionInfo": { - "EncryptionAtRest": { - "DataVolumeKMSKeyId": "arn:aws:kms:us-east-1:644160558196:key/133b4e81-8447-4c40-83cd-1db75d52b106" - }, - "EncryptionInTransit": { - "ClientBroker": "TLS_PLAINTEXT", - "InCluster": true - } - }, - "EnhancedMonitoring": "DEFAULT", - "OpenMonitoring": { - "Prometheus": { - "JmxExporter": { - "EnabledInBroker": false - }, - "NodeExporter": { - "EnabledInBroker": false - } - } - }, - "NumberOfBrokerNodes": 2, - "State": "ACTIVE", - "Tags": {}, - "ZookeeperConnectString": "z-1.demo-cluster-1.1pyhj3.c14.kafka.us-east-1.amazonaws.com:2181,z-2.demo-cluster-1.1pyhj3.c14.kafka.us-east-1.amazonaws.com:2181,z-3.demo-cluster-1.1pyhj3.c14.kafka.us-east-1.amazonaws.com:2181", - "ZookeeperConnectStringTls": "z-1.demo-cluster-1.1pyhj3.c14.kafka.us-east-1.amazonaws.com:2182,z-2.demo-cluster-1.1pyhj3.c14.kafka.us-east-1.amazonaws.com:2182,z-3.demo-cluster-1.1pyhj3.c14.kafka.us-east-1.amazonaws.com:2182" - } - ] - } -} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_cluster_kms_filter/kms.DescribeKey_1.json b/tests/data/placebo/test_kafka_cluster_kms_filter/kms.DescribeKey_1.json index dd0817e80af..11892bc8cf8 100644 --- a/tests/data/placebo/test_kafka_cluster_kms_filter/kms.DescribeKey_1.json +++ b/tests/data/placebo/test_kafka_cluster_kms_filter/kms.DescribeKey_1.json @@ -3,25 +3,26 @@ "data": { "KeyMetadata": { "AWSAccountId": "644160558196", - "KeyId": "133b4e81-8447-4c40-83cd-1db75d52b106", - "Arn": "arn:aws:kms:us-east-1:644160558196:key/133b4e81-8447-4c40-83cd-1db75d52b106", + "KeyId": "d0e564f4-ec4c-43bd-b379-a22f92253dbe", + "Arn": "arn:aws:kms:ap-northeast-2:644160558196:key/d0e564f4-ec4c-43bd-b379-a22f92253dbe", "CreationDate": { "__class__": "datetime", - "year": 2019, - "month": 1, - "day": 30, - "hour": 10, - "minute": 11, - "second": 4, - "microsecond": 829000 + "year": 2022, + "month": 12, + "day": 9, + "hour": 15, + "minute": 13, + "second": 39, + "microsecond": 35000 }, "Enabled": true, - "Description": "Default master key that protects my Kafka data when no other key is defined", + "Description": "Default key that protects my Kafka data when no other key is defined", "KeyUsage": "ENCRYPT_DECRYPT", "KeyState": "Enabled", "Origin": "AWS_KMS", "KeyManager": "AWS", "CustomerMasterKeySpec": "SYMMETRIC_DEFAULT", + "KeySpec": "SYMMETRIC_DEFAULT", "EncryptionAlgorithms": [ "SYMMETRIC_DEFAULT" ], diff --git a/tests/data/placebo/test_kafka_cluster_kms_filter/kms.ListAliases_1.json b/tests/data/placebo/test_kafka_cluster_kms_filter/kms.ListAliases_1.json index 9e694ad561e..edb0c246495 100644 --- a/tests/data/placebo/test_kafka_cluster_kms_filter/kms.ListAliases_1.json +++ b/tests/data/placebo/test_kafka_cluster_kms_filter/kms.ListAliases_1.json @@ -2,29 +2,227 @@ "status_code": 200, "data": { "Aliases": [ + { + "AliasName": "alias/aws/dynamodb", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/dynamodb" + }, + { + "AliasName": "alias/aws/ebs", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/ebs" + }, + { + "AliasName": "alias/aws/elasticfilesystem", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/elasticfilesystem" + }, + { + "AliasName": "alias/aws/es", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/es" + }, + { + "AliasName": "alias/aws/glue", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/glue" + }, { "AliasName": "alias/aws/kafka", - "AliasArn": "arn:aws:kms:us-east-1:644160558196:alias/aws/kafka", - "TargetKeyId": "133b4e81-8447-4c40-83cd-1db75d52b106", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/kafka", + "TargetKeyId": "d0e564f4-ec4c-43bd-b379-a22f92253dbe", + "CreationDate": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 9, + "hour": 15, + "minute": 13, + "second": 39, + "microsecond": 173000 + }, + "LastUpdatedDate": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 9, + "hour": 15, + "minute": 13, + "second": 39, + "microsecond": 173000 + } + }, + { + "AliasName": "alias/aws/kinesisvideo", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/kinesisvideo" + }, + { + "AliasName": "alias/aws/lambda", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/lambda", + "TargetKeyId": "3f6dc1e2-3b43-4fa7-9114-5290fd4bbfc0", + "CreationDate": { + "__class__": "datetime", + "year": 2022, + "month": 3, + "day": 29, + "hour": 17, + "minute": 51, + "second": 22, + "microsecond": 65000 + }, + "LastUpdatedDate": { + "__class__": "datetime", + "year": 2022, + "month": 3, + "day": 29, + "hour": 17, + "minute": 51, + "second": 22, + "microsecond": 65000 + } + }, + { + "AliasName": "alias/aws/rds", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/rds" + }, + { + "AliasName": "alias/aws/redshift", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/redshift" + }, + { + "AliasName": "alias/aws/redshifttest", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/redshifttest" + }, + { + "AliasName": "alias/aws/s3", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/s3" + }, + { + "AliasName": "alias/aws/sns", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/sns", + "TargetKeyId": "e033425f-2d43-45e1-b404-cc86549b3621", + "CreationDate": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 9, + "hour": 12, + "minute": 7, + "second": 16, + "microsecond": 535000 + }, + "LastUpdatedDate": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 9, + "hour": 12, + "minute": 7, + "second": 16, + "microsecond": 535000 + } + }, + { + "AliasName": "alias/aws/ssm", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/ssm" + }, + { + "AliasName": "alias/aws/xray", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/xray" + }, + { + "AliasName": "alias/sandbox-regional-db-execution", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/sandbox-regional-db-execution", + "TargetKeyId": "f0a247a2-b089-4876-a886-ecde526961b1", + "CreationDate": { + "__class__": "datetime", + "year": 2022, + "month": 9, + "day": 21, + "hour": 12, + "minute": 46, + "second": 15, + "microsecond": 680000 + }, + "LastUpdatedDate": { + "__class__": "datetime", + "year": 2022, + "month": 9, + "day": 21, + "hour": 12, + "minute": 46, + "second": 15, + "microsecond": 680000 + } + }, + { + "AliasName": "alias/sandbox/execution-queue", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/sandbox/execution-queue", + "TargetKeyId": "0c776c05-6b3f-4e74-ba00-0ac59969d0c2", + "CreationDate": { + "__class__": "datetime", + "year": 2022, + "month": 9, + "day": 21, + "hour": 12, + "minute": 46, + "second": 16, + "microsecond": 696000 + }, + "LastUpdatedDate": { + "__class__": "datetime", + "year": 2022, + "month": 9, + "day": 21, + "hour": 12, + "minute": 46, + "second": 16, + "microsecond": 696000 + } + }, + { + "AliasName": "alias/sandbox/execution/env", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/sandbox/execution/env", + "TargetKeyId": "335722f1-a330-4f23-a338-8544297eae0c", + "CreationDate": { + "__class__": "datetime", + "year": 2022, + "month": 9, + "day": 21, + "hour": 12, + "minute": 46, + "second": 14, + "microsecond": 669000 + }, + "LastUpdatedDate": { + "__class__": "datetime", + "year": 2022, + "month": 9, + "day": 21, + "hour": 12, + "minute": 46, + "second": 14, + "microsecond": 669000 + } + }, + { + "AliasName": "alias/skunk/trails", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/skunk/trails", + "TargetKeyId": "4e587a21-567d-4504-aa8e-879b1b98ca15", "CreationDate": { "__class__": "datetime", - "year": 2019, - "month": 1, - "day": 30, - "hour": 10, - "minute": 11, - "second": 4, - "microsecond": 839000 + "year": 2022, + "month": 12, + "day": 9, + "hour": 12, + "minute": 8, + "second": 27, + "microsecond": 381000 }, "LastUpdatedDate": { "__class__": "datetime", - "year": 2019, - "month": 1, - "day": 30, - "hour": 10, - "minute": 11, - "second": 4, - "microsecond": 839000 + "year": 2022, + "month": 12, + "day": 9, + "hour": 12, + "minute": 8, + "second": 27, + "microsecond": 381000 } } ], diff --git a/tests/data/placebo/test_kafka_cluster_kms_filter/kms.ListAliases_2.json b/tests/data/placebo/test_kafka_cluster_kms_filter/kms.ListAliases_2.json index 9e694ad561e..2769e88e02b 100644 --- a/tests/data/placebo/test_kafka_cluster_kms_filter/kms.ListAliases_2.json +++ b/tests/data/placebo/test_kafka_cluster_kms_filter/kms.ListAliases_2.json @@ -4,27 +4,27 @@ "Aliases": [ { "AliasName": "alias/aws/kafka", - "AliasArn": "arn:aws:kms:us-east-1:644160558196:alias/aws/kafka", - "TargetKeyId": "133b4e81-8447-4c40-83cd-1db75d52b106", + "AliasArn": "arn:aws:kms:ap-northeast-2:644160558196:alias/aws/kafka", + "TargetKeyId": "d0e564f4-ec4c-43bd-b379-a22f92253dbe", "CreationDate": { "__class__": "datetime", - "year": 2019, - "month": 1, - "day": 30, - "hour": 10, - "minute": 11, - "second": 4, - "microsecond": 839000 + "year": 2022, + "month": 12, + "day": 9, + "hour": 15, + "minute": 13, + "second": 39, + "microsecond": 173000 }, "LastUpdatedDate": { "__class__": "datetime", - "year": 2019, - "month": 1, - "day": 30, - "hour": 10, - "minute": 11, - "second": 4, - "microsecond": 839000 + "year": 2022, + "month": 12, + "day": 9, + "hour": 15, + "minute": 13, + "second": 39, + "microsecond": 173000 } } ], diff --git a/tests/data/placebo/test_kafka_cluster_provisioned_and_serverless/kafka.ListClustersV2_1.json b/tests/data/placebo/test_kafka_cluster_provisioned_and_serverless/kafka.ListClustersV2_1.json new file mode 100644 index 00000000000..00b4c593e52 --- /dev/null +++ b/tests/data/placebo/test_kafka_cluster_provisioned_and_serverless/kafka.ListClustersV2_1.json @@ -0,0 +1,112 @@ +{ + "status_code": 200, + "data": { + "ResponseMetadata": {}, + "ClusterInfoList": [ + { + "ClusterType": "PROVISIONED", + "ClusterArn": "arn:aws:kafka:us-east-1:644160558196:cluster/c7n-provisioned-26354/43417a68-9303-426d-a5db-28a56ed26e67-2", + "ClusterName": "c7n-provisioned-26354", + "CreationTime": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 15, + "hour": 21, + "minute": 23, + "second": 29, + "microsecond": 72000 + }, + "CurrentVersion": "K2EUQ1WTGCTBG2", + "State": "CREATING", + "Tags": {}, + "Provisioned": { + "BrokerNodeGroupInfo": { + "BrokerAZDistribution": "DEFAULT", + "ClientSubnets": [ + "subnet-08f5a2e4c12adf737", + "subnet-00e4b6ccbf5f49a9e" + ], + "InstanceType": "kafka.m5.large", + "SecurityGroups": [ + "sg-0e5c97dfc455dc571" + ], + "StorageInfo": { + "EbsStorageInfo": { + "VolumeSize": 100 + } + }, + "ConnectivityInfo": { + "PublicAccess": { + "Type": "DISABLED" + } + } + }, + "CurrentBrokerSoftwareInfo": { + "KafkaVersion": "3.2.0" + }, + "EncryptionInfo": { + "EncryptionAtRest": { + "DataVolumeKMSKeyId": "arn:aws:kms:us-east-1:644160558196:key/c6c0b5d4-506b-4d2e-8748-9a939b129b96" + }, + "EncryptionInTransit": { + "ClientBroker": "TLS", + "InCluster": true + } + }, + "EnhancedMonitoring": "DEFAULT", + "OpenMonitoring": { + "Prometheus": { + "JmxExporter": { + "EnabledInBroker": false + }, + "NodeExporter": { + "EnabledInBroker": false + } + } + }, + "NumberOfBrokerNodes": 2, + "StorageMode": "LOCAL" + } + }, + { + "ClusterType": "SERVERLESS", + "ClusterArn": "arn:aws:kafka:us-east-1:644160558196:cluster/c7n-serverless-26354/1c1e16aa-4089-4593-9c2b-b43bbc48ff00-s1", + "ClusterName": "c7n-serverless-26354", + "CreationTime": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 15, + "hour": 21, + "minute": 23, + "second": 28, + "microsecond": 418000 + }, + "CurrentVersion": "K2EUQ1WTGCTBG2", + "State": "ACTIVE", + "Tags": {}, + "Serverless": { + "VpcConfigs": [ + { + "SubnetIds": [ + "subnet-08f5a2e4c12adf737", + "subnet-00e4b6ccbf5f49a9e" + ], + "SecurityGroupIds": [ + "sg-0e5c97dfc455dc571" + ] + } + ], + "ClientAuthentication": { + "Sasl": { + "Iam": { + "Enabled": true + } + } + } + } + } + ] + } +} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_delete/kafka.DeleteCluster_1.json b/tests/data/placebo/test_kafka_delete/kafka.DeleteCluster_1.json index 451a20d1e43..c7f1f38369a 100644 --- a/tests/data/placebo/test_kafka_delete/kafka.DeleteCluster_1.json +++ b/tests/data/placebo/test_kafka_delete/kafka.DeleteCluster_1.json @@ -1,24 +1,8 @@ { "status_code": 200, "data": { - "ResponseMetadata": { - "RequestId": "03e84107-24af-11e9-a8cd-41093073219c", - "HTTPStatusCode": 200, - "HTTPHeaders": { - "content-type": "application/json", - "content-length": "123", - "connection": "keep-alive", - "date": "Wed, 30 Jan 2019 16:49:32 GMT", - "x-amzn-requestid": "03e84107-24af-11e9-a8cd-41093073219c", - "x-amz-apigw-id": "UU5QSGLBIAMF8Tw=", - "x-amzn-trace-id": "Root=1-5c51d59b-7112e188a1824f74e8765fd0;Sampled=0", - "x-cache": "Miss from cloudfront", - "via": "1.1 e6d15137ec23376f4c8a22e6edb289bd.cloudfront.net (CloudFront)", - "x-amz-cf-id": "YfAaxUTmjnjo7EE2isWtG8ABWmyp7wM1nUwxL1KxOofV6lWEWU-ngw==" - }, - "RetryAttempts": 0 - }, - "ClusterArn": "arn:aws:kafka:us-east-1:644160558196:cluster/dev/fde9077e-25d9-4292-918a-c299ca3086c2-2", + "ResponseMetadata": {}, + "ClusterArn": "arn:aws:kafka:ap-northeast-2:644160558196:cluster/demo-cluster-1/a4128f17-d0a5-4b03-b858-ea13108e7286-4", "State": "DELETING" } } \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_delete/kafka.DescribeCluster_1.json b/tests/data/placebo/test_kafka_delete/kafka.DescribeCluster_1.json index 35dd2bae8e2..9f0cf015392 100644 --- a/tests/data/placebo/test_kafka_delete/kafka.DescribeCluster_1.json +++ b/tests/data/placebo/test_kafka_delete/kafka.DescribeCluster_1.json @@ -1,62 +1,88 @@ { "status_code": 200, "data": { - "ResponseMetadata": { - "RequestId": "07a04004-24af-11e9-9104-c94ac64d028f", - "HTTPStatusCode": 200, - "HTTPHeaders": { - "content-type": "application/json", - "content-length": "696", - "connection": "keep-alive", - "date": "Wed, 30 Jan 2019 16:49:37 GMT", - "x-amzn-requestid": "07a04004-24af-11e9-9104-c94ac64d028f", - "x-amz-apigw-id": "UU5RRHQSoAMFqMg=", - "x-amzn-trace-id": "Root=1-5c51d5a1-22ba125cb490a118cb34b4d0;Sampled=0", - "x-cache": "Miss from cloudfront", - "via": "1.1 29206f4909cacc031d06a0daf330fb6a.cloudfront.net (CloudFront)", - "x-amz-cf-id": "P_-QZiAnbQXQfd8Vu_U8_c69nYsI4qtWmaCVHFeiFH-38exOcauCWw==" - }, - "RetryAttempts": 0 - }, + "ResponseMetadata": {}, "ClusterInfo": { "BrokerNodeGroupInfo": { "BrokerAZDistribution": "DEFAULT", "ClientSubnets": [ - "subnet-914763e7", - "subnet-3a334610", - "subnet-efbcccb7" + "subnet-04f91d4b", + "subnet-efc87884", + "subnet-2418755f" ], "InstanceType": "kafka.m5.large", + "SecurityGroups": [ + "sg-bd0718c6" + ], "StorageInfo": { "EbsStorageInfo": { - "VolumeSize": 1000 + "VolumeSize": 100 + } + }, + "ConnectivityInfo": { + "PublicAccess": { + "Type": "DISABLED" } } }, - "ClusterArn": "arn:aws:kafka:us-east-1:644160558196:cluster/dev/fde9077e-25d9-4292-918a-c299ca3086c2-2", - "ClusterName": "dev", + "ClientAuthentication": { + "Sasl": { + "Scram": { + "Enabled": false + }, + "Iam": { + "Enabled": true + } + }, + "Tls": { + "CertificateAuthorityArnList": [], + "Enabled": false + }, + "Unauthenticated": { + "Enabled": false + } + }, + "ClusterArn": "arn:aws:kafka:ap-northeast-2:644160558196:cluster/demo-cluster-1/a4128f17-d0a5-4b03-b858-ea13108e7286-4", + "ClusterName": "demo-cluster-1", "CreationTime": { "__class__": "datetime", - "year": 2019, - "month": 1, - "day": 30, - "hour": 15, - "minute": 11, - "second": 5, - "microsecond": 58000 + "year": 2022, + "month": 12, + "day": 9, + "hour": 23, + "minute": 13, + "second": 39, + "microsecond": 670000 }, "CurrentBrokerSoftwareInfo": { - "KafkaVersion": "1.1.1" + "KafkaVersion": "2.8.1" }, - "CurrentVersion": "K2EUQ1WTGCTBG2", + "CurrentVersion": "KGZZ1ST63LKBW", "EncryptionInfo": { "EncryptionAtRest": { - "DataVolumeKMSKeyId": "arn:aws:kms:us-east-1:644160558196:key/133b4e81-8447-4c40-83cd-1db75d52b106" + "DataVolumeKMSKeyId": "arn:aws:kms:ap-northeast-2:644160558196:key/d0e564f4-ec4c-43bd-b379-a22f92253dbe" + }, + "EncryptionInTransit": { + "ClientBroker": "TLS", + "InCluster": true + } + }, + "EnhancedMonitoring": "PER_BROKER", + "OpenMonitoring": { + "Prometheus": { + "JmxExporter": { + "EnabledInBroker": true + }, + "NodeExporter": { + "EnabledInBroker": false + } } }, - "EnhancedMonitoring": "DEFAULT", "NumberOfBrokerNodes": 3, - "State": "DELETING" + "State": "DELETING", + "Tags": { + "App": "Custodian" + } } } } \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_delete/kafka.ListClustersV2_1.json b/tests/data/placebo/test_kafka_delete/kafka.ListClustersV2_1.json new file mode 100644 index 00000000000..2de2e1961e6 --- /dev/null +++ b/tests/data/placebo/test_kafka_delete/kafka.ListClustersV2_1.json @@ -0,0 +1,95 @@ +{ + "status_code": 200, + "data": { + "ResponseMetadata": {}, + "ClusterInfoList": [ + { + "ClusterType": "PROVISIONED", + "ClusterArn": "arn:aws:kafka:ap-northeast-2:644160558196:cluster/demo-cluster-1/a4128f17-d0a5-4b03-b858-ea13108e7286-4", + "ClusterName": "demo-cluster-1", + "CreationTime": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 9, + "hour": 23, + "minute": 13, + "second": 39, + "microsecond": 670000 + }, + "CurrentVersion": "K3FE7AD5N5R11", + "State": "ACTIVE", + "Tags": { + "App": "Custodian" + }, + "Provisioned": { + "BrokerNodeGroupInfo": { + "BrokerAZDistribution": "DEFAULT", + "ClientSubnets": [ + "subnet-04f91d4b", + "subnet-efc87884", + "subnet-2418755f" + ], + "InstanceType": "kafka.m5.large", + "SecurityGroups": [ + "sg-bd0718c6" + ], + "StorageInfo": { + "EbsStorageInfo": { + "VolumeSize": 100 + } + }, + "ConnectivityInfo": { + "PublicAccess": { + "Type": "DISABLED" + } + } + }, + "CurrentBrokerSoftwareInfo": { + "KafkaVersion": "2.8.1" + }, + "ClientAuthentication": { + "Sasl": { + "Scram": { + "Enabled": false + }, + "Iam": { + "Enabled": true + } + }, + "Tls": { + "CertificateAuthorityArnList": [], + "Enabled": false + }, + "Unauthenticated": { + "Enabled": false + } + }, + "EncryptionInfo": { + "EncryptionAtRest": { + "DataVolumeKMSKeyId": "arn:aws:kms:ap-northeast-2:644160558196:key/d0e564f4-ec4c-43bd-b379-a22f92253dbe" + }, + "EncryptionInTransit": { + "ClientBroker": "TLS", + "InCluster": true + } + }, + "EnhancedMonitoring": "PER_BROKER", + "OpenMonitoring": { + "Prometheus": { + "JmxExporter": { + "EnabledInBroker": true + }, + "NodeExporter": { + "EnabledInBroker": false + } + } + }, + "NumberOfBrokerNodes": 3, + "ZookeeperConnectString": "z-3.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181,z-1.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181,z-2.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181", + "ZookeeperConnectStringTls": "z-3.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182,z-1.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182,z-2.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182" + } + } + ] + } +} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_delete/kafka.ListClusters_1.json b/tests/data/placebo/test_kafka_delete/kafka.ListClusters_1.json deleted file mode 100644 index 68548412f4d..00000000000 --- a/tests/data/placebo/test_kafka_delete/kafka.ListClusters_1.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "status_code": 200, - "data": { - "ResponseMetadata": { - "RequestId": "03a51d29-24af-11e9-854e-57ebf68ef044", - "HTTPStatusCode": 200, - "HTTPHeaders": { - "content-type": "application/json", - "content-length": "780", - "connection": "keep-alive", - "date": "Wed, 30 Jan 2019 16:49:31 GMT", - "x-amzn-requestid": "03a51d29-24af-11e9-854e-57ebf68ef044", - "x-amz-apigw-id": "UU5QOHQsoAMFe6Q=", - "x-amzn-trace-id": "Root=1-5c51d59b-62f7e840a126d668f101abd8;Sampled=0", - "x-cache": "Miss from cloudfront", - "via": "1.1 6e24e95f882f20707346a032d1fa2949.cloudfront.net (CloudFront)", - "x-amz-cf-id": "qLGhWGTy4fnTd0sXPiNunmJwxRDZO-Zeks57qlDfsrQkKkPlcEez7g==" - }, - "RetryAttempts": 0 - }, - "ClusterInfoList": [ - { - "BrokerNodeGroupInfo": { - "BrokerAZDistribution": "DEFAULT", - "ClientSubnets": [ - "subnet-914763e7", - "subnet-3a334610", - "subnet-efbcccb7" - ], - "InstanceType": "kafka.m5.large", - "StorageInfo": { - "EbsStorageInfo": { - "VolumeSize": 1000 - } - } - }, - "ClusterArn": "arn:aws:kafka:us-east-1:644160558196:cluster/dev/fde9077e-25d9-4292-918a-c299ca3086c2-2", - "ClusterName": "dev", - "CreationTime": { - "__class__": "datetime", - "year": 2019, - "month": 1, - "day": 30, - "hour": 15, - "minute": 11, - "second": 5, - "microsecond": 58000 - }, - "CurrentBrokerSoftwareInfo": { - "KafkaVersion": "1.1.1" - }, - "CurrentVersion": "K13V1IB3VIYZZH", - "EncryptionInfo": { - "EncryptionAtRest": { - "DataVolumeKMSKeyId": "arn:aws:kms:us-east-1:644160558196:key/133b4e81-8447-4c40-83cd-1db75d52b106" - } - }, - "EnhancedMonitoring": "DEFAULT", - "NumberOfBrokerNodes": 3, - "State": "ACTIVE", - "ZookeeperConnectString": "172.31.62.2:2181,172.31.31.72:2181,172.31.3.127:2181" - } - ] - } -} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_set_monitoring/kafka.DescribeCluster_1.json b/tests/data/placebo/test_kafka_set_monitoring/kafka.DescribeCluster_1.json index a40d85f9e6e..4ce482206d1 100644 --- a/tests/data/placebo/test_kafka_set_monitoring/kafka.DescribeCluster_1.json +++ b/tests/data/placebo/test_kafka_set_monitoring/kafka.DescribeCluster_1.json @@ -1,80 +1,91 @@ { - "status_code": 200, - "data": { - "ResponseMetadata": {}, - "ClusterInfo": { - "ActiveOperationArn": "arn:aws:kafka:us-east-1:644160558196:cluster-operation/dev/d9776364-2d39-4f56-90b4-1961339ee936-6/4bf20bb0-f6a5-4148-abe7-f04f022001e6", - "BrokerNodeGroupInfo": { - "BrokerAZDistribution": "DEFAULT", - "ClientSubnets": [ - "subnet-914763e7", - "subnet-3a334610" - ], - "InstanceType": "kafka.m5.large", - "SecurityGroups": [ - "sg-6c7fa917" - ], - "StorageInfo": { - "EbsStorageInfo": { - "VolumeSize": 1000 - } + "status_code": 200, + "data": { + "ResponseMetadata": {}, + "ClusterInfo": { + "ActiveOperationArn": "arn:aws:kafka:ap-northeast-2:644160558196:cluster-operation/demo-cluster-1/a4128f17-d0a5-4b03-b858-ea13108e7286-4/825acbb9-a77d-4920-9b08-61ab158251bb", + "BrokerNodeGroupInfo": { + "BrokerAZDistribution": "DEFAULT", + "ClientSubnets": [ + "subnet-04f91d4b", + "subnet-efc87884", + "subnet-2418755f" + ], + "InstanceType": "kafka.m5.large", + "SecurityGroups": [ + "sg-bd0718c6" + ], + "StorageInfo": { + "EbsStorageInfo": { + "VolumeSize": 100 + } + }, + "ConnectivityInfo": { + "PublicAccess": { + "Type": "DISABLED" + } + } + }, + "ClientAuthentication": { + "Sasl": { + "Scram": { + "Enabled": false + }, + "Iam": { + "Enabled": true + } + }, + "Tls": { + "CertificateAuthorityArnList": [], + "Enabled": false + }, + "Unauthenticated": { + "Enabled": false + } + }, + "ClusterArn": "arn:aws:kafka:ap-northeast-2:644160558196:cluster/demo-cluster-1/a4128f17-d0a5-4b03-b858-ea13108e7286-4", + "ClusterName": "demo-cluster-1", + "CreationTime": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 9, + "hour": 23, + "minute": 13, + "second": 39, + "microsecond": 670000 + }, + "CurrentBrokerSoftwareInfo": { + "KafkaVersion": "2.8.1" + }, + "CurrentVersion": "K3LJ5WMKNRFKQS", + "EncryptionInfo": { + "EncryptionAtRest": { + "DataVolumeKMSKeyId": "arn:aws:kms:ap-northeast-2:644160558196:key/d0e564f4-ec4c-43bd-b379-a22f92253dbe" + }, + "EncryptionInTransit": { + "ClientBroker": "TLS", + "InCluster": true + } + }, + "EnhancedMonitoring": "DEFAULT", + "OpenMonitoring": { + "Prometheus": { + "JmxExporter": { + "EnabledInBroker": false + }, + "NodeExporter": { + "EnabledInBroker": false + } + } + }, + "NumberOfBrokerNodes": 3, + "State": "UPDATING", + "Tags": { + "App": "Custodian" + }, + "ZookeeperConnectString": "z-3.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181,z-1.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181,z-2.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181", + "ZookeeperConnectStringTls": "z-3.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182,z-1.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182,z-2.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182" } - }, - "ClusterArn": "arn:aws:kafka:us-east-1:644160558196:cluster/dev/d9776364-2d39-4f56-90b4-1961339ee936-6", - "ClusterName": "dev", - "CreationTime": { - "__class__": "datetime", - "year": 2020, - "month": 3, - "day": 28, - "hour": 15, - "minute": 18, - "second": 2, - "microsecond": 620000 - }, - "CurrentBrokerSoftwareInfo": { - "KafkaVersion": "2.2.1" - }, - "CurrentVersion": "K1IM4EOPHS76S7", - "EncryptionInfo": { - "EncryptionAtRest": { - "DataVolumeKMSKeyId": "arn:aws:kms:us-east-1:644160558196:key/133b4e81-8447-4c40-83cd-1db75d52b106" - }, - "EncryptionInTransit": { - "ClientBroker": "TLS", - "InCluster": true - } - }, - "EnhancedMonitoring": "DEFAULT", - "OpenMonitoring": { - "Prometheus": { - "JmxExporter": { - "EnabledInBroker": true - }, - "NodeExporter": { - "EnabledInBroker": false - } - } - }, - "LoggingInfo": { - "BrokerLogs": { - "CloudWatchLogs": { - "Enabled": false - }, - "Firehose": { - "Enabled": false - }, - "S3": { - "Enabled": false - } - } - }, - "NumberOfBrokerNodes": 2, - "State": "UPDATING", - "Tags": { - "App": "Custodian" - }, - "ZookeeperConnectString": "z-2.dev.rwngrp.c6.kafka.us-east-1.amazonaws.com:2181,z-1.dev.rwngrp.c6.kafka.us-east-1.amazonaws.com:2181,z-3.dev.rwngrp.c6.kafka.us-east-1.amazonaws.com:2181" } - } } \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_set_monitoring/kafka.ListClustersV2_1.json b/tests/data/placebo/test_kafka_set_monitoring/kafka.ListClustersV2_1.json new file mode 100644 index 00000000000..47714a7eed3 --- /dev/null +++ b/tests/data/placebo/test_kafka_set_monitoring/kafka.ListClustersV2_1.json @@ -0,0 +1,95 @@ +{ + "status_code": 200, + "data": { + "ResponseMetadata": {}, + "ClusterInfoList": [ + { + "ClusterType": "PROVISIONED", + "ClusterArn": "arn:aws:kafka:ap-northeast-2:644160558196:cluster/demo-cluster-1/a4128f17-d0a5-4b03-b858-ea13108e7286-4", + "ClusterName": "demo-cluster-1", + "CreationTime": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 9, + "hour": 23, + "minute": 13, + "second": 39, + "microsecond": 670000 + }, + "CurrentVersion": "K138L1TOL8PIJT", + "State": "ACTIVE", + "Tags": { + "App": "Custodian" + }, + "Provisioned": { + "BrokerNodeGroupInfo": { + "BrokerAZDistribution": "DEFAULT", + "ClientSubnets": [ + "subnet-04f91d4b", + "subnet-efc87884", + "subnet-2418755f" + ], + "InstanceType": "kafka.m5.large", + "SecurityGroups": [ + "sg-bd0718c6" + ], + "StorageInfo": { + "EbsStorageInfo": { + "VolumeSize": 100 + } + }, + "ConnectivityInfo": { + "PublicAccess": { + "Type": "DISABLED" + } + } + }, + "CurrentBrokerSoftwareInfo": { + "KafkaVersion": "2.8.1" + }, + "ClientAuthentication": { + "Sasl": { + "Scram": { + "Enabled": false + }, + "Iam": { + "Enabled": true + } + }, + "Tls": { + "CertificateAuthorityArnList": [], + "Enabled": false + }, + "Unauthenticated": { + "Enabled": false + } + }, + "EncryptionInfo": { + "EncryptionAtRest": { + "DataVolumeKMSKeyId": "arn:aws:kms:ap-northeast-2:644160558196:key/d0e564f4-ec4c-43bd-b379-a22f92253dbe" + }, + "EncryptionInTransit": { + "ClientBroker": "TLS", + "InCluster": true + } + }, + "EnhancedMonitoring": "DEFAULT", + "OpenMonitoring": { + "Prometheus": { + "JmxExporter": { + "EnabledInBroker": false + }, + "NodeExporter": { + "EnabledInBroker": false + } + } + }, + "NumberOfBrokerNodes": 3, + "ZookeeperConnectString": "z-3.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181,z-1.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181,z-2.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181", + "ZookeeperConnectStringTls": "z-3.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182,z-1.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182,z-2.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182" + } + } + ] + } +} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_set_monitoring/kafka.ListClusters_1.json b/tests/data/placebo/test_kafka_set_monitoring/kafka.ListClusters_1.json deleted file mode 100644 index 6230e725135..00000000000 --- a/tests/data/placebo/test_kafka_set_monitoring/kafka.ListClusters_1.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "status_code": 200, - "data": { - "ResponseMetadata": {}, - "ClusterInfoList": [ - { - "BrokerNodeGroupInfo": { - "BrokerAZDistribution": "DEFAULT", - "ClientSubnets": [ - "subnet-914763e7", - "subnet-3a334610" - ], - "InstanceType": "kafka.m5.large", - "SecurityGroups": [ - "sg-6c7fa917" - ], - "StorageInfo": { - "EbsStorageInfo": { - "VolumeSize": 1000 - } - } - }, - "ClusterArn": "arn:aws:kafka:us-east-1:644160558196:cluster/dev/d9776364-2d39-4f56-90b4-1961339ee936-6", - "ClusterName": "dev", - "CreationTime": { - "__class__": "datetime", - "year": 2020, - "month": 3, - "day": 28, - "hour": 15, - "minute": 18, - "second": 2, - "microsecond": 620000 - }, - "CurrentBrokerSoftwareInfo": { - "KafkaVersion": "2.2.1" - }, - "CurrentVersion": "K3DWYIK6Y9EEQB", - "EncryptionInfo": { - "EncryptionAtRest": { - "DataVolumeKMSKeyId": "arn:aws:kms:us-east-1:644160558196:key/133b4e81-8447-4c40-83cd-1db75d52b106" - }, - "EncryptionInTransit": { - "ClientBroker": "TLS", - "InCluster": true - } - }, - "EnhancedMonitoring": "DEFAULT", - "OpenMonitoring": { - "Prometheus": { - "JmxExporter": { - "EnabledInBroker": true - }, - "NodeExporter": { - "EnabledInBroker": false - } - } - }, - "LoggingInfo": { - "BrokerLogs": { - "CloudWatchLogs": { - "Enabled": false - }, - "Firehose": { - "Enabled": false - }, - "S3": { - "Enabled": false - } - } - }, - "NumberOfBrokerNodes": 2, - "State": "ACTIVE", - "Tags": { - "App": "Custodian" - }, - "ZookeeperConnectString": "z-2.dev.rwngrp.c6.kafka.us-east-1.amazonaws.com:2181,z-1.dev.rwngrp.c6.kafka.us-east-1.amazonaws.com:2181,z-3.dev.rwngrp.c6.kafka.us-east-1.amazonaws.com:2181" - } - ] - } -} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_set_monitoring/kafka.UpdateMonitoring_1.json b/tests/data/placebo/test_kafka_set_monitoring/kafka.UpdateMonitoring_1.json index 75b184d97bf..5ee463ef671 100644 --- a/tests/data/placebo/test_kafka_set_monitoring/kafka.UpdateMonitoring_1.json +++ b/tests/data/placebo/test_kafka_set_monitoring/kafka.UpdateMonitoring_1.json @@ -1,8 +1,8 @@ { - "status_code": 200, - "data": { - "ResponseMetadata": {}, - "ClusterArn": "arn:aws:kafka:us-east-1:644160558196:cluster/dev/d9776364-2d39-4f56-90b4-1961339ee936-6", - "ClusterOperationArn": "arn:aws:kafka:us-east-1:644160558196:cluster-operation/dev/d9776364-2d39-4f56-90b4-1961339ee936-6/4bf20bb0-f6a5-4148-abe7-f04f022001e6" - } + "status_code": 200, + "data": { + "ResponseMetadata": {}, + "ClusterArn": "arn:aws:kafka:ap-northeast-2:644160558196:cluster/demo-cluster-1/a4128f17-d0a5-4b03-b858-ea13108e7286-4", + "ClusterOperationArn": "arn:aws:kafka:ap-northeast-2:644160558196:cluster-operation/demo-cluster-1/a4128f17-d0a5-4b03-b858-ea13108e7286-4/825acbb9-a77d-4920-9b08-61ab158251bb" + } } \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_subnet_filter/ec2.DescribeSubnets_1.json b/tests/data/placebo/test_kafka_subnet_filter/ec2.DescribeSubnets_1.json index e27d1f24ede..3c7329a08b2 100644 --- a/tests/data/placebo/test_kafka_subnet_filter/ec2.DescribeSubnets_1.json +++ b/tests/data/placebo/test_kafka_subnet_filter/ec2.DescribeSubnets_1.json @@ -3,15 +3,16 @@ "data": { "Subnets": [ { - "AvailabilityZone": "us-east-1d", - "AvailabilityZoneId": "use1-az2", - "AvailableIpAddressCount": 4086, - "CidrBlock": "172.31.48.0/20", + "AvailabilityZone": "ap-northeast-2c", + "AvailabilityZoneId": "apne2-az3", + "AvailableIpAddressCount": 4089, + "CidrBlock": "172.31.32.0/20", "DefaultForAz": true, "MapPublicIpOnLaunch": true, + "MapCustomerOwnedIpOnLaunch": false, "State": "available", - "SubnetId": "subnet-3a334610", - "VpcId": "vpc-d2d616b5", + "SubnetId": "subnet-04f91d4b", + "VpcId": "vpc-b6189fdd", "OwnerId": "644160558196", "AssignIpv6AddressOnCreation": false, "Ipv6CidrBlockAssociationSet": [], @@ -19,72 +20,64 @@ { "Key": "NetworkLocation", "Value": "Public" - }, - { - "Key": "Name", - "Value": "Default-48" } ], - "SubnetArn": "arn:aws:ec2:us-east-1:644160558196:subnet/subnet-3a334610" + "SubnetArn": "arn:aws:ec2:ap-northeast-2:644160558196:subnet/subnet-04f91d4b", + "EnableDns64": false, + "Ipv6Native": false, + "PrivateDnsNameOptionsOnLaunch": { + "HostnameType": "ip-name", + "EnableResourceNameDnsARecord": false, + "EnableResourceNameDnsAAAARecord": false + } }, { - "AvailabilityZone": "us-east-1b", - "AvailabilityZoneId": "use1-az6", - "AvailableIpAddressCount": 4088, - "CidrBlock": "172.31.16.0/20", + "AvailabilityZone": "ap-northeast-2a", + "AvailabilityZoneId": "apne2-az1", + "AvailableIpAddressCount": 4089, + "CidrBlock": "172.31.0.0/20", "DefaultForAz": true, "MapPublicIpOnLaunch": true, + "MapCustomerOwnedIpOnLaunch": false, "State": "available", - "SubnetId": "subnet-efbcccb7", - "VpcId": "vpc-d2d616b5", + "SubnetId": "subnet-efc87884", + "VpcId": "vpc-b6189fdd", "OwnerId": "644160558196", "AssignIpv6AddressOnCreation": false, "Ipv6CidrBlockAssociationSet": [], - "Tags": [ - { - "Key": "NetworkLocation", - "Value": "Public" - }, - { - "Key": "Name", - "Value": "" - } - ], - "SubnetArn": "arn:aws:ec2:us-east-1:644160558196:subnet/subnet-efbcccb7" + "SubnetArn": "arn:aws:ec2:ap-northeast-2:644160558196:subnet/subnet-efc87884", + "EnableDns64": false, + "Ipv6Native": false, + "PrivateDnsNameOptionsOnLaunch": { + "HostnameType": "ip-name", + "EnableResourceNameDnsARecord": false, + "EnableResourceNameDnsAAAARecord": false + } }, { - "AvailabilityZone": "us-east-1a", - "AvailabilityZoneId": "use1-az4", - "AvailableIpAddressCount": 4086, - "CidrBlock": "172.31.0.0/20", + "AvailabilityZone": "ap-northeast-2b", + "AvailabilityZoneId": "apne2-az2", + "AvailableIpAddressCount": 4089, + "CidrBlock": "172.31.16.0/20", "DefaultForAz": true, "MapPublicIpOnLaunch": true, + "MapCustomerOwnedIpOnLaunch": false, "State": "available", - "SubnetId": "subnet-914763e7", - "VpcId": "vpc-d2d616b5", + "SubnetId": "subnet-2418755f", + "VpcId": "vpc-b6189fdd", "OwnerId": "644160558196", "AssignIpv6AddressOnCreation": false, "Ipv6CidrBlockAssociationSet": [], - "Tags": [ - { - "Key": "NetworkLocation", - "Value": "Public" - } - ], - "SubnetArn": "arn:aws:ec2:us-east-1:644160558196:subnet/subnet-914763e7" + "SubnetArn": "arn:aws:ec2:ap-northeast-2:644160558196:subnet/subnet-2418755f", + "EnableDns64": false, + "Ipv6Native": false, + "PrivateDnsNameOptionsOnLaunch": { + "HostnameType": "ip-name", + "EnableResourceNameDnsARecord": false, + "EnableResourceNameDnsAAAARecord": false + } } ], - "ResponseMetadata": { - "RequestId": "ffcd3c58-3ead-4758-bf5c-728b61da9811", - "HTTPStatusCode": 200, - "HTTPHeaders": { - "content-type": "text/xml;charset=UTF-8", - "content-length": "3294", - "vary": "Accept-Encoding", - "date": "Wed, 30 Jan 2019 16:46:09 GMT", - "server": "AmazonEC2" - }, - "RetryAttempts": 0 - } + "ResponseMetadata": {} } } \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_subnet_filter/kafka.ListClustersV2_1.json b/tests/data/placebo/test_kafka_subnet_filter/kafka.ListClustersV2_1.json new file mode 100644 index 00000000000..8a2a18ac51e --- /dev/null +++ b/tests/data/placebo/test_kafka_subnet_filter/kafka.ListClustersV2_1.json @@ -0,0 +1,95 @@ +{ + "status_code": 200, + "data": { + "ResponseMetadata": {}, + "ClusterInfoList": [ + { + "ClusterType": "PROVISIONED", + "ClusterArn": "arn:aws:kafka:ap-northeast-2:644160558196:cluster/demo-cluster-1/a4128f17-d0a5-4b03-b858-ea13108e7286-4", + "ClusterName": "demo-cluster-1", + "CreationTime": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 9, + "hour": 23, + "minute": 13, + "second": 39, + "microsecond": 670000 + }, + "CurrentVersion": "K3P5ROKL5A1OLE", + "State": "ACTIVE", + "Tags": { + "Env": "Dev" + }, + "Provisioned": { + "BrokerNodeGroupInfo": { + "BrokerAZDistribution": "DEFAULT", + "ClientSubnets": [ + "subnet-04f91d4b", + "subnet-efc87884", + "subnet-2418755f" + ], + "InstanceType": "kafka.m5.large", + "SecurityGroups": [ + "sg-bd0718c6" + ], + "StorageInfo": { + "EbsStorageInfo": { + "VolumeSize": 100 + } + }, + "ConnectivityInfo": { + "PublicAccess": { + "Type": "DISABLED" + } + } + }, + "CurrentBrokerSoftwareInfo": { + "KafkaVersion": "2.8.1" + }, + "ClientAuthentication": { + "Sasl": { + "Scram": { + "Enabled": false + }, + "Iam": { + "Enabled": true + } + }, + "Tls": { + "CertificateAuthorityArnList": [], + "Enabled": false + }, + "Unauthenticated": { + "Enabled": false + } + }, + "EncryptionInfo": { + "EncryptionAtRest": { + "DataVolumeKMSKeyId": "arn:aws:kms:ap-northeast-2:644160558196:key/d0e564f4-ec4c-43bd-b379-a22f92253dbe" + }, + "EncryptionInTransit": { + "ClientBroker": "TLS", + "InCluster": true + } + }, + "EnhancedMonitoring": "DEFAULT", + "OpenMonitoring": { + "Prometheus": { + "JmxExporter": { + "EnabledInBroker": false + }, + "NodeExporter": { + "EnabledInBroker": false + } + } + }, + "NumberOfBrokerNodes": 3, + "ZookeeperConnectString": "z-3.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181,z-1.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181,z-2.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181", + "ZookeeperConnectStringTls": "z-3.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182,z-1.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182,z-2.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182" + } + } + ] + } +} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_subnet_filter/kafka.ListClusters_1.json b/tests/data/placebo/test_kafka_subnet_filter/kafka.ListClusters_1.json deleted file mode 100644 index 8b9d80e7be1..00000000000 --- a/tests/data/placebo/test_kafka_subnet_filter/kafka.ListClusters_1.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "status_code": 200, - "data": { - "ResponseMetadata": { - "RequestId": "8be571ee-24ae-11e9-87dd-057c990a4f84", - "HTTPStatusCode": 200, - "HTTPHeaders": { - "content-type": "application/json", - "content-length": "780", - "connection": "keep-alive", - "date": "Wed, 30 Jan 2019 16:46:10 GMT", - "x-amzn-requestid": "8be571ee-24ae-11e9-87dd-057c990a4f84", - "x-amz-apigw-id": "UU4w1GXOIAMF_SQ=", - "x-amzn-trace-id": "Root=1-5c51d4d2-aedba9c0d3aad63c0b55947a;Sampled=0", - "x-cache": "Miss from cloudfront", - "via": "1.1 c62f6c9a9fdf2356a904a1b156a05fe1.cloudfront.net (CloudFront)", - "x-amz-cf-id": "f2i9dlk1cgGE3YFTVz6diqQYldiD2IXPCQe9zca06pTv6GRXvsC8wQ==" - }, - "RetryAttempts": 0 - }, - "ClusterInfoList": [ - { - "BrokerNodeGroupInfo": { - "BrokerAZDistribution": "DEFAULT", - "ClientSubnets": [ - "subnet-914763e7", - "subnet-3a334610", - "subnet-efbcccb7" - ], - "InstanceType": "kafka.m5.large", - "StorageInfo": { - "EbsStorageInfo": { - "VolumeSize": 1000 - } - } - }, - "ClusterArn": "arn:aws:kafka:us-east-1:644160558196:cluster/dev/fde9077e-25d9-4292-918a-c299ca3086c2-2", - "ClusterName": "dev", - "CreationTime": { - "__class__": "datetime", - "year": 2019, - "month": 1, - "day": 30, - "hour": 15, - "minute": 11, - "second": 5, - "microsecond": 58000 - }, - "CurrentBrokerSoftwareInfo": { - "KafkaVersion": "1.1.1" - }, - "CurrentVersion": "K13V1IB3VIYZZH", - "EncryptionInfo": { - "EncryptionAtRest": { - "DataVolumeKMSKeyId": "arn:aws:kms:us-east-1:644160558196:key/133b4e81-8447-4c40-83cd-1db75d52b106" - } - }, - "EnhancedMonitoring": "DEFAULT", - "NumberOfBrokerNodes": 3, - "State": "ACTIVE", - "ZookeeperConnectString": "172.31.62.2:2181,172.31.31.72:2181,172.31.3.127:2181" - } - ] - } -} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_subnet_filter_provisioned_serverless/ec2.DescribeSubnets_1.json b/tests/data/placebo/test_kafka_subnet_filter_provisioned_serverless/ec2.DescribeSubnets_1.json new file mode 100644 index 00000000000..51fdb85ef05 --- /dev/null +++ b/tests/data/placebo/test_kafka_subnet_filter_provisioned_serverless/ec2.DescribeSubnets_1.json @@ -0,0 +1,74 @@ +{ + "status_code": 200, + "data": { + "Subnets": [ + { + "AvailabilityZone": "us-east-1a", + "AvailabilityZoneId": "use1-az4", + "AvailableIpAddressCount": 4090, + "CidrBlock": "10.0.0.0/20", + "DefaultForAz": false, + "MapPublicIpOnLaunch": true, + "MapCustomerOwnedIpOnLaunch": false, + "State": "available", + "SubnetId": "subnet-00e4b6ccbf5f49a9e", + "VpcId": "vpc-091903ea8ede06de5", + "OwnerId": "644160558196", + "AssignIpv6AddressOnCreation": false, + "Ipv6CidrBlockAssociationSet": [], + "Tags": [ + { + "Key": "AZ", + "Value": "us-east-1a" + }, + { + "Key": "Name", + "Value": "dev Stacklet VPC Private Subnet us-east-1a" + } + ], + "SubnetArn": "arn:aws:ec2:us-east-1:644160558196:subnet/subnet-00e4b6ccbf5f49a9e", + "EnableDns64": false, + "Ipv6Native": false, + "PrivateDnsNameOptionsOnLaunch": { + "HostnameType": "ip-name", + "EnableResourceNameDnsARecord": false, + "EnableResourceNameDnsAAAARecord": false + } + }, + { + "AvailabilityZone": "us-east-1b", + "AvailabilityZoneId": "use1-az6", + "AvailableIpAddressCount": 4090, + "CidrBlock": "10.0.16.0/20", + "DefaultForAz": false, + "MapPublicIpOnLaunch": true, + "MapCustomerOwnedIpOnLaunch": false, + "State": "available", + "SubnetId": "subnet-08f5a2e4c12adf737", + "VpcId": "vpc-091903ea8ede06de5", + "OwnerId": "644160558196", + "AssignIpv6AddressOnCreation": false, + "Ipv6CidrBlockAssociationSet": [], + "Tags": [ + { + "Key": "AZ", + "Value": "us-east-1b" + }, + { + "Key": "Name", + "Value": "dev Stacklet VPC Private Subnet us-east-1b" + } + ], + "SubnetArn": "arn:aws:ec2:us-east-1:644160558196:subnet/subnet-08f5a2e4c12adf737", + "EnableDns64": false, + "Ipv6Native": false, + "PrivateDnsNameOptionsOnLaunch": { + "HostnameType": "ip-name", + "EnableResourceNameDnsARecord": false, + "EnableResourceNameDnsAAAARecord": false + } + } + ], + "ResponseMetadata": {} + } +} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_subnet_filter_provisioned_serverless/ec2.DescribeSubnets_2.json b/tests/data/placebo/test_kafka_subnet_filter_provisioned_serverless/ec2.DescribeSubnets_2.json new file mode 100644 index 00000000000..51fdb85ef05 --- /dev/null +++ b/tests/data/placebo/test_kafka_subnet_filter_provisioned_serverless/ec2.DescribeSubnets_2.json @@ -0,0 +1,74 @@ +{ + "status_code": 200, + "data": { + "Subnets": [ + { + "AvailabilityZone": "us-east-1a", + "AvailabilityZoneId": "use1-az4", + "AvailableIpAddressCount": 4090, + "CidrBlock": "10.0.0.0/20", + "DefaultForAz": false, + "MapPublicIpOnLaunch": true, + "MapCustomerOwnedIpOnLaunch": false, + "State": "available", + "SubnetId": "subnet-00e4b6ccbf5f49a9e", + "VpcId": "vpc-091903ea8ede06de5", + "OwnerId": "644160558196", + "AssignIpv6AddressOnCreation": false, + "Ipv6CidrBlockAssociationSet": [], + "Tags": [ + { + "Key": "AZ", + "Value": "us-east-1a" + }, + { + "Key": "Name", + "Value": "dev Stacklet VPC Private Subnet us-east-1a" + } + ], + "SubnetArn": "arn:aws:ec2:us-east-1:644160558196:subnet/subnet-00e4b6ccbf5f49a9e", + "EnableDns64": false, + "Ipv6Native": false, + "PrivateDnsNameOptionsOnLaunch": { + "HostnameType": "ip-name", + "EnableResourceNameDnsARecord": false, + "EnableResourceNameDnsAAAARecord": false + } + }, + { + "AvailabilityZone": "us-east-1b", + "AvailabilityZoneId": "use1-az6", + "AvailableIpAddressCount": 4090, + "CidrBlock": "10.0.16.0/20", + "DefaultForAz": false, + "MapPublicIpOnLaunch": true, + "MapCustomerOwnedIpOnLaunch": false, + "State": "available", + "SubnetId": "subnet-08f5a2e4c12adf737", + "VpcId": "vpc-091903ea8ede06de5", + "OwnerId": "644160558196", + "AssignIpv6AddressOnCreation": false, + "Ipv6CidrBlockAssociationSet": [], + "Tags": [ + { + "Key": "AZ", + "Value": "us-east-1b" + }, + { + "Key": "Name", + "Value": "dev Stacklet VPC Private Subnet us-east-1b" + } + ], + "SubnetArn": "arn:aws:ec2:us-east-1:644160558196:subnet/subnet-08f5a2e4c12adf737", + "EnableDns64": false, + "Ipv6Native": false, + "PrivateDnsNameOptionsOnLaunch": { + "HostnameType": "ip-name", + "EnableResourceNameDnsARecord": false, + "EnableResourceNameDnsAAAARecord": false + } + } + ], + "ResponseMetadata": {} + } +} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_subnet_filter_provisioned_serverless/kafka.ListClustersV2_1.json b/tests/data/placebo/test_kafka_subnet_filter_provisioned_serverless/kafka.ListClustersV2_1.json new file mode 100644 index 00000000000..98005a8379e --- /dev/null +++ b/tests/data/placebo/test_kafka_subnet_filter_provisioned_serverless/kafka.ListClustersV2_1.json @@ -0,0 +1,112 @@ +{ + "status_code": 200, + "data": { + "ResponseMetadata": {}, + "ClusterInfoList": [ + { + "ClusterType": "PROVISIONED", + "ClusterArn": "arn:aws:kafka:us-east-1:644160558196:cluster/c7n-provisioned-44487/b0febde2-4cc6-480e-b662-11533a176872-2", + "ClusterName": "c7n-provisioned-44487", + "CreationTime": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 15, + "hour": 21, + "minute": 56, + "second": 55, + "microsecond": 585000 + }, + "CurrentVersion": "K1PA6795UKMFR9", + "State": "CREATING", + "Tags": {}, + "Provisioned": { + "BrokerNodeGroupInfo": { + "BrokerAZDistribution": "DEFAULT", + "ClientSubnets": [ + "subnet-08f5a2e4c12adf737", + "subnet-00e4b6ccbf5f49a9e" + ], + "InstanceType": "kafka.m5.large", + "SecurityGroups": [ + "sg-0e5c97dfc455dc571" + ], + "StorageInfo": { + "EbsStorageInfo": { + "VolumeSize": 100 + } + }, + "ConnectivityInfo": { + "PublicAccess": { + "Type": "DISABLED" + } + } + }, + "CurrentBrokerSoftwareInfo": { + "KafkaVersion": "3.2.0" + }, + "EncryptionInfo": { + "EncryptionAtRest": { + "DataVolumeKMSKeyId": "arn:aws:kms:us-east-1:644160558196:key/c6c0b5d4-506b-4d2e-8748-9a939b129b96" + }, + "EncryptionInTransit": { + "ClientBroker": "TLS", + "InCluster": true + } + }, + "EnhancedMonitoring": "DEFAULT", + "OpenMonitoring": { + "Prometheus": { + "JmxExporter": { + "EnabledInBroker": false + }, + "NodeExporter": { + "EnabledInBroker": false + } + } + }, + "NumberOfBrokerNodes": 2, + "StorageMode": "LOCAL" + } + }, + { + "ClusterType": "SERVERLESS", + "ClusterArn": "arn:aws:kafka:us-east-1:644160558196:cluster/c7n-serverless-44487/b8b1bcc2-0ab6-459e-a7e2-50977fa1e40b-s2", + "ClusterName": "c7n-serverless-44487", + "CreationTime": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 15, + "hour": 21, + "minute": 56, + "second": 55, + "microsecond": 381000 + }, + "CurrentVersion": "K2EUQ1WTGCTBG2", + "State": "ACTIVE", + "Tags": {}, + "Serverless": { + "VpcConfigs": [ + { + "SubnetIds": [ + "subnet-08f5a2e4c12adf737", + "subnet-00e4b6ccbf5f49a9e" + ], + "SecurityGroupIds": [ + "sg-0e5c97dfc455dc571" + ] + } + ], + "ClientAuthentication": { + "Sasl": { + "Iam": { + "Enabled": true + } + } + } + } + } + ] + } +} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_tag/kafka.ListClustersV2_1.json b/tests/data/placebo/test_kafka_tag/kafka.ListClustersV2_1.json new file mode 100644 index 00000000000..8a2a18ac51e --- /dev/null +++ b/tests/data/placebo/test_kafka_tag/kafka.ListClustersV2_1.json @@ -0,0 +1,95 @@ +{ + "status_code": 200, + "data": { + "ResponseMetadata": {}, + "ClusterInfoList": [ + { + "ClusterType": "PROVISIONED", + "ClusterArn": "arn:aws:kafka:ap-northeast-2:644160558196:cluster/demo-cluster-1/a4128f17-d0a5-4b03-b858-ea13108e7286-4", + "ClusterName": "demo-cluster-1", + "CreationTime": { + "__class__": "datetime", + "year": 2022, + "month": 12, + "day": 9, + "hour": 23, + "minute": 13, + "second": 39, + "microsecond": 670000 + }, + "CurrentVersion": "K3P5ROKL5A1OLE", + "State": "ACTIVE", + "Tags": { + "Env": "Dev" + }, + "Provisioned": { + "BrokerNodeGroupInfo": { + "BrokerAZDistribution": "DEFAULT", + "ClientSubnets": [ + "subnet-04f91d4b", + "subnet-efc87884", + "subnet-2418755f" + ], + "InstanceType": "kafka.m5.large", + "SecurityGroups": [ + "sg-bd0718c6" + ], + "StorageInfo": { + "EbsStorageInfo": { + "VolumeSize": 100 + } + }, + "ConnectivityInfo": { + "PublicAccess": { + "Type": "DISABLED" + } + } + }, + "CurrentBrokerSoftwareInfo": { + "KafkaVersion": "2.8.1" + }, + "ClientAuthentication": { + "Sasl": { + "Scram": { + "Enabled": false + }, + "Iam": { + "Enabled": true + } + }, + "Tls": { + "CertificateAuthorityArnList": [], + "Enabled": false + }, + "Unauthenticated": { + "Enabled": false + } + }, + "EncryptionInfo": { + "EncryptionAtRest": { + "DataVolumeKMSKeyId": "arn:aws:kms:ap-northeast-2:644160558196:key/d0e564f4-ec4c-43bd-b379-a22f92253dbe" + }, + "EncryptionInTransit": { + "ClientBroker": "TLS", + "InCluster": true + } + }, + "EnhancedMonitoring": "DEFAULT", + "OpenMonitoring": { + "Prometheus": { + "JmxExporter": { + "EnabledInBroker": false + }, + "NodeExporter": { + "EnabledInBroker": false + } + } + }, + "NumberOfBrokerNodes": 3, + "ZookeeperConnectString": "z-3.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181,z-1.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181,z-2.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2181", + "ZookeeperConnectStringTls": "z-3.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182,z-1.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182,z-2.democluster1.ltt504.c4.kafka.ap-northeast-2.amazonaws.com:2182" + } + } + ] + } +} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_tag/kafka.ListClusters_1.json b/tests/data/placebo/test_kafka_tag/kafka.ListClusters_1.json deleted file mode 100644 index 1a9743b4c45..00000000000 --- a/tests/data/placebo/test_kafka_tag/kafka.ListClusters_1.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "status_code": 200, - "data": { - "ResponseMetadata": {}, - "ClusterInfoList": [ - { - "BrokerNodeGroupInfo": { - "BrokerAZDistribution": "DEFAULT", - "ClientSubnets": [ - "subnet-914763e7", - "subnet-3a334610" - ], - "InstanceType": "kafka.m5.large", - "SecurityGroups": [ - "sg-6c7fa917" - ], - "StorageInfo": { - "EbsStorageInfo": { - "VolumeSize": 1000 - } - } - }, - "ClusterArn": "arn:aws:kafka:us-east-1:644160558196:cluster/dev/d9776364-2d39-4f56-90b4-1961339ee936-6", - "ClusterName": "dev", - "CreationTime": { - "__class__": "datetime", - "year": 2020, - "month": 3, - "day": 28, - "hour": 15, - "minute": 18, - "second": 2, - "microsecond": 620000 - }, - "CurrentBrokerSoftwareInfo": { - "KafkaVersion": "2.2.1" - }, - "CurrentVersion": "K3AEGXETSR30VB", - "EncryptionInfo": { - "EncryptionAtRest": { - "DataVolumeKMSKeyId": "arn:aws:kms:us-east-1:644160558196:key/133b4e81-8447-4c40-83cd-1db75d52b106" - }, - "EncryptionInTransit": { - "ClientBroker": "TLS", - "InCluster": true - } - }, - "EnhancedMonitoring": "DEFAULT", - "OpenMonitoring": { - "Prometheus": { - "JmxExporter": { - "EnabledInBroker": false - }, - "NodeExporter": { - "EnabledInBroker": false - } - } - }, - "LoggingInfo": { - "BrokerLogs": { - "CloudWatchLogs": { - "Enabled": false - }, - "Firehose": { - "Enabled": false - }, - "S3": { - "Enabled": false - } - } - }, - "NumberOfBrokerNodes": 2, - "State": "ACTIVE", - "Tags": { - "Env": "Dev" - }, - "ZookeeperConnectString": "z-2.dev.rwngrp.c6.kafka.us-east-1.amazonaws.com:2181,z-1.dev.rwngrp.c6.kafka.us-east-1.amazonaws.com:2181,z-3.dev.rwngrp.c6.kafka.us-east-1.amazonaws.com:2181" - } - ] - } -} \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_tag/kafka.ListTagsForResource_1.json b/tests/data/placebo/test_kafka_tag/kafka.ListTagsForResource_1.json index 487803d398c..5820ab5162f 100644 --- a/tests/data/placebo/test_kafka_tag/kafka.ListTagsForResource_1.json +++ b/tests/data/placebo/test_kafka_tag/kafka.ListTagsForResource_1.json @@ -1,9 +1,9 @@ { - "status_code": 200, - "data": { - "ResponseMetadata": {}, - "Tags": { - "App": "Custodian" + "status_code": 200, + "data": { + "ResponseMetadata": {}, + "Tags": { + "App": "Custodian" + } } - } } \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_tag/tagging.TagResources_1.json b/tests/data/placebo/test_kafka_tag/tagging.TagResources_1.json index 5881a0de84f..bd2dead8598 100644 --- a/tests/data/placebo/test_kafka_tag/tagging.TagResources_1.json +++ b/tests/data/placebo/test_kafka_tag/tagging.TagResources_1.json @@ -1,7 +1,7 @@ { - "status_code": 200, - "data": { - "FailedResourcesMap": {}, - "ResponseMetadata": {} - } + "status_code": 200, + "data": { + "FailedResourcesMap": {}, + "ResponseMetadata": {} + } } \ No newline at end of file diff --git a/tests/data/placebo/test_kafka_tag/tagging.UntagResources_1.json b/tests/data/placebo/test_kafka_tag/tagging.UntagResources_1.json index 5881a0de84f..bd2dead8598 100644 --- a/tests/data/placebo/test_kafka_tag/tagging.UntagResources_1.json +++ b/tests/data/placebo/test_kafka_tag/tagging.UntagResources_1.json @@ -1,7 +1,7 @@ { - "status_code": 200, - "data": { - "FailedResourcesMap": {}, - "ResponseMetadata": {} - } + "status_code": 200, + "data": { + "FailedResourcesMap": {}, + "ResponseMetadata": {} + } } \ No newline at end of file diff --git a/tests/test_kafka.py b/tests/test_kafka.py index 28a6a927e42..d81caea1119 100644 --- a/tests/test_kafka.py +++ b/tests/test_kafka.py @@ -25,10 +25,29 @@ def test_subnet_filter(self): {'type': 'subnet', 'key': 'tag:NetworkLocation', 'value': 'Public'}]}, - session_factory=factory) + session_factory=factory, + config={'region': 'ap-northeast-2'}) resources = p.run() self.assertEqual(len(resources), 1) + def test_subnet_filter_provisioned_serverless(self): + factory = self.replay_flight_data('test_kafka_subnet_filter_provisioned_serverless') + p = self.load_policy({ + 'name': 'kafka', + 'resource': 'aws.kafka', + 'filters': [ + {'type': 'subnet', + 'key': 'AvailabilityZone', + 'value': 'us-east-1b'}]}, + session_factory=factory,) + resources = p.run() + self.assertEqual(len(resources), 2) + self.assertEqual(resources[0]['ClusterType'], 'PROVISIONED') + self.assertEqual(resources[0]['c7n:matched-subnets'], ['subnet-08f5a2e4c12adf737']) + + self.assertEqual(resources[1]['ClusterType'], 'SERVERLESS') + self.assertEqual(resources[1]['c7n:matched-subnets'], ['subnet-08f5a2e4c12adf737']) + def test_kafka_tag(self): factory = self.replay_flight_data('test_kafka_tag') p = self.load_policy({ @@ -42,11 +61,13 @@ def test_kafka_tag(self): 'tags': {'App': 'Custodian'}}, {'type': 'remove-tag', 'tags': ['Env']}]}, - session_factory=factory) + session_factory=factory, + config={'region': 'ap-northeast-2'} + ) resources = p.run() assert len(resources) == 1 - assert resources[0]['ClusterName'] == 'dev' - client = factory().client('kafka') + assert resources[0]['ClusterName'] == 'demo-cluster-1' + client = factory().client('kafka', region_name='ap-northeast-2') assert client.list_tags_for_resource( ResourceArn=resources[0]['ClusterArn'])['Tags'] == { 'App': 'Custodian'} @@ -69,14 +90,15 @@ def test_set_monitoring(self): 'Prometheus': { 'JmxExporter': { 'EnabledInBroker': True}}}}}]}, - session_factory=factory) + session_factory=factory, + config={'region': 'ap-northeast-2'}) resources = p.run() assert len(resources) == 1 - assert resources[0]['ClusterName'] == 'dev' + assert resources[0]['ClusterName'] == 'demo-cluster-1' if self.recording: time.sleep(5) - info = factory().client('kafka').describe_cluster( + info = factory().client('kafka', region_name='ap-northeast-2').describe_cluster( ClusterArn=resources[0]['ClusterArn'])['ClusterInfo'] assert info['State'] == 'UPDATING' @@ -87,25 +109,26 @@ def test_delete(self): 'name': 'kafka', 'resource': 'aws.kafka', 'filters': [ - {'ClusterName': 'dev'}], + {'ClusterName': 'demo-cluster-1'}], 'actions': [ {'type': 'delete'}, ]}, - session_factory=factory) + session_factory=factory, + config={'region': 'ap-northeast-2'}) resources = p.run() self.assertEqual(len(resources), 1) if self.recording: time.sleep(5) - client = factory().client('kafka') + client = factory().client('kafka', region_name='ap-northeast-2') cluster = client.describe_cluster(ClusterArn=resources[0]['ClusterArn']).get('ClusterInfo') self.assertEqual(cluster['State'], 'DELETING') def test_kafka_cluster_kms_filter(self): session_factory = self.replay_flight_data('test_kafka_cluster_kms_filter') - kms = session_factory().client('kms') - expression = 'EncryptionInfo.EncryptionAtRest.DataVolumeKMSKeyId' + kms = session_factory().client('kms', region_name='ap-northeast-2') + expression = 'Provisioned.EncryptionInfo.EncryptionAtRest.DataVolumeKMSKeyId' p = self.load_policy( { 'name': 'kafka-kms-filter', @@ -118,9 +141,25 @@ def test_kafka_cluster_kms_filter(self): } ] }, - session_factory=session_factory + session_factory=session_factory, + config={'region': 'ap-northeast-2'} ) resources = p.run() self.assertEqual(len(resources), 1) aliases = kms.list_aliases(KeyId=(jmespath.search(expression, resources[0]))) self.assertEqual(aliases['Aliases'][0]['AliasName'], 'alias/aws/kafka') + + def test_kafka_cluster_provisioned_and_serverless(self): + session_factory = self.replay_flight_data( + 'test_kafka_cluster_provisioned_and_serverless') + p = self.load_policy( + { + 'name': 'kafka-kms-filter', + 'resource': 'kafka', + }, + session_factory=session_factory, + ) + resources = p.run() + self.assertEqual(len(resources), 2) + self.assertEqual(resources[0]['ClusterType'], 'PROVISIONED') + self.assertEqual(resources[1]['ClusterType'], 'SERVERLESS')