Skip to content

Commit

Permalink
chore: remove region relationships
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Dec 19, 2024
1 parent a8f29a1 commit 052f257
Showing 1 changed file with 10 additions and 34 deletions.
44 changes: 10 additions & 34 deletions scrapers/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -1045,13 +1045,6 @@ func (aws Scraper) vpcs(ctx *AWSContext, config v1.AWS, results *v1.ScrapeResult
Relationship: "VPCDHCPOptions",
})

// VPC to region relationship
relationships = append(relationships, v1.RelationshipResult{
RelatedExternalID: v1.ExternalID{ExternalID: string(*vpc.VpcId), ConfigType: v1.AWSEC2VPC},
ConfigExternalID: v1.ExternalID{ExternalID: ctx.Session.Region, ConfigType: v1.AWSRegion},
Relationship: "RegionVPC",
})

labels := getLabels(vpc.Tags)
labels["network"] = *vpc.VpcId

Expand Down Expand Up @@ -1150,12 +1143,6 @@ func (aws Scraper) instances(ctx *AWSContext, config v1.AWS, results *v1.ScrapeR
Relationship: "SubnetInstance",
})

relationships = append(relationships, v1.RelationshipResult{
ConfigExternalID: v1.ExternalID{ExternalID: ctx.Session.Region, ConfigType: v1.AWSRegion},
RelatedExternalID: selfExternalID,
Relationship: "RegionInstance",
})

instance := NewInstance(i)
labels := instance.Tags
if labels == nil {
Expand Down Expand Up @@ -1620,28 +1607,17 @@ func (aws Scraper) subnets(ctx *AWSContext, config v1.AWS, results *v1.ScrapeRes
return
}

var relationships []v1.RelationshipResult
selfExternalID := v1.ExternalID{ExternalID: lo.FromPtr(subnet.SubnetId), ConfigType: v1.AWSEC2Subnet}

// Subnet to Region relationship
relationships = append(relationships, v1.RelationshipResult{
RelatedExternalID: selfExternalID,
ConfigExternalID: v1.ExternalID{ExternalID: ctx.Session.Region, ConfigType: v1.AWSRegion},
Relationship: "RegionSubnet",
})

result := v1.ScrapeResult{
Type: v1.AWSEC2Subnet,
Status: string(subnet.State),
BaseScraper: config.BaseScraper,
Labels: labels,
Tags: tags,
ConfigClass: "Subnet",
ID: *subnet.SubnetId,
Config: subnet,
Parents: []v1.ConfigExternalKey{{Type: v1.AWSEC2VPC, ExternalID: lo.FromPtr(subnet.VpcId)}},
Properties: []*types.Property{getConsoleLink(ctx.Session.Region, v1.AWSEC2Subnet, lo.FromPtr(subnet.SubnetId), nil)},
RelationshipResults: relationships,
Type: v1.AWSEC2Subnet,
Status: string(subnet.State),
BaseScraper: config.BaseScraper,
Labels: labels,
Tags: tags,
ConfigClass: "Subnet",
ID: *subnet.SubnetId,
Config: subnet,
Parents: []v1.ConfigExternalKey{{Type: v1.AWSEC2VPC, ExternalID: lo.FromPtr(subnet.VpcId)}},
Properties: []*types.Property{getConsoleLink(ctx.Session.Region, v1.AWSEC2Subnet, lo.FromPtr(subnet.SubnetId), nil)},
}

*results = append(*results, result)
Expand Down

0 comments on commit 052f257

Please sign in to comment.