Skip to content

Commit

Permalink
feat: updated implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
1101-1 committed Oct 30, 2024
1 parent 279cd86 commit c1771b6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions plugins/aws/fix_plugin_aws/resource/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c1771b6

Please sign in to comment.