From c1771b671f7c000fce3bded5f7370b95181c7d92 Mon Sep 17 00:00:00 2001 From: Kirill Date: Wed, 30 Oct 2024 14:12:59 +0000 Subject: [PATCH] feat: updated implementation --- plugins/aws/fix_plugin_aws/resource/ec2.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/aws/fix_plugin_aws/resource/ec2.py b/plugins/aws/fix_plugin_aws/resource/ec2.py index c0374f01fe..4035911c9c 100644 --- a/plugins/aws/fix_plugin_aws/resource/ec2.py +++ b/plugins/aws/fix_plugin_aws/resource/ec2.py @@ -497,6 +497,10 @@ def collect(cls: Type[AwsResource], json: List[Json], builder: GraphBuilder) -> def service_name(cls) -> Optional[str]: return service_name + @classmethod + def called_collect_apis(cls) -> List[AwsApiSpec]: + return [AwsApiSpec(service_name, "describe-instance-types")] + # endregion @@ -1408,14 +1412,13 @@ class AwsEc2Instance(EC2Taggable, AwsResource, BaseInstance): @classmethod def collect_resources(cls: Type[AwsResource], builder: GraphBuilder) -> None: super().collect_resources(builder) # type: ignore # mypy bug: https://github.com/python/mypy/issues/12885 - ec2_instance_types = [] - checked_types = set() + ec2_instance_types = set() for instance in builder.nodes(clazz=AwsEc2Instance): - if (instance_type := instance.instance_type) and instance_type not in checked_types: - ec2_instance_types.append(instance_type) - checked_types.add(instance_type) + ec2_instance_types.add(instance.instance_type) if ec2_instance_types: - builder.submit_work(service_name, AwsEc2InstanceType.collect_resource_types, builder, ec2_instance_types) + builder.submit_work( + service_name, AwsEc2InstanceType.collect_resource_types, builder, list(ec2_instance_types) + ) @classmethod def collect(cls: Type[AwsResource], json: List[Json], builder: GraphBuilder) -> None: