Skip to content

Commit d41709e

Browse files
authored
[aws][fix]: Fix non acyclic graph connection (#2118)
1 parent b884916 commit d41709e

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

plugins/aws/fix_plugin_aws/resource/backup.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
from attrs import define, field
66

77
from fix_plugin_aws.resource.base import AwsResource, AwsApiSpec, GraphBuilder
8+
from fix_plugin_aws.resource.cloudformation import AwsCloudFormationStack
9+
from fix_plugin_aws.resource.dynamodb import AwsDynamoDbTable, AwsDynamoDbGlobalTable
10+
from fix_plugin_aws.resource.ec2 import AwsEc2Instance, AwsEc2Volume
11+
from fix_plugin_aws.resource.efs import AwsEfsFileSystem
12+
from fix_plugin_aws.resource.rds import AwsRdsCluster, AwsRdsInstance
13+
from fix_plugin_aws.resource.redshift import AwsRedshiftCluster
14+
from fix_plugin_aws.resource.s3 import AwsS3Bucket
815
from fix_plugin_aws.utils import TagsValue
916
from fixlib.baseresources import ModelReference
1017
from fixlib.json_bender import Bender, S, ForallBend, Bend
@@ -172,7 +179,6 @@ class AwsBackupProtectedResource(AwsResource):
172179
"resource_name": S("ResourceName"),
173180
"last_backup_vault_arn": S("LastBackupVaultArn"),
174181
"last_recovery_point_arn": S("LastRecoveryPointArn"),
175-
"arn": S("ResourceArn"),
176182
}
177183
resource_arn: Optional[str] = field(default=None, metadata={"description": "An Amazon Resource Name (ARN) that uniquely identifies a resource. The format of the ARN depends on the resource type."}) # fmt: skip
178184
resource_type: Optional[str] = field(default=None, metadata={"description": "The type of Amazon Web Services resource; for example, an Amazon Elastic Block Store (Amazon EBS) volume or an Amazon Relational Database Service (Amazon RDS) database. For Windows Volume Shadow Copy Service (VSS) backups, the only supported resource type is Amazon EC2."}) # fmt: skip
@@ -183,7 +189,22 @@ class AwsBackupProtectedResource(AwsResource):
183189

184190
def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None:
185191
if resource_arn := self.resource_arn:
186-
builder.add_edge(self, clazz=AwsResource, arn=resource_arn)
192+
builder.add_edge(
193+
self,
194+
clazz=(
195+
AwsS3Bucket,
196+
AwsEc2Instance,
197+
AwsEc2Volume,
198+
AwsRdsCluster,
199+
AwsRdsInstance,
200+
AwsDynamoDbTable,
201+
AwsDynamoDbGlobalTable,
202+
AwsEfsFileSystem,
203+
AwsRedshiftCluster,
204+
AwsCloudFormationStack,
205+
),
206+
arn=resource_arn,
207+
)
187208
if vault_arn := self.last_backup_vault_arn:
188209
builder.add_edge(self, reverse=True, clazz=AwsBackupVault, id=vault_arn)
189210
if recovery_point_arn := self.last_recovery_point_arn:

plugins/aws/test/collector_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def count_kind(clazz: Type[AwsResource]) -> int:
3434
assert len(threading.enumerate()) == 1
3535
# ensure the correct number of nodes and edges
3636
assert count_kind(AwsResource) == 236
37-
assert len(account_collector.graph.edges) == 540
37+
assert len(account_collector.graph.edges) == 539
3838
assert len(account_collector.graph.deferred_edges) == 2
3939
for node in account_collector.graph.nodes:
4040
if isinstance(node, AwsRegion):

0 commit comments

Comments
 (0)