Skip to content

Commit

Permalink
correctly propagate ec2 instance region (#44623)
Browse files Browse the repository at this point in the history
this PR correctly propagates the region of a certain EC2 instance instead of relying on availability zone.

Signed-off-by: Tiago Silva <[email protected]>
  • Loading branch information
tigrato authored Jul 25, 2024
1 parent 71edce0 commit a190ede
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/srv/discovery/fetchers/aws-sync/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (a *awsFetcher) fetchAWSEC2Instances(ctx context.Context) ([]*accessgraphv1
lHosts := make([]*accessgraphv1alpha.AWSInstanceV1, 0, len(page.Reservations))
for _, reservation := range page.Reservations {
for _, instance := range reservation.Instances {
hosts = append(hosts, awsInstanceToProtoInstance(instance, a.AccountID))
hosts = append(hosts, awsInstanceToProtoInstance(instance, region, a.AccountID))
}
}
collectHosts(lHosts, nil)
Expand All @@ -110,7 +110,7 @@ func (a *awsFetcher) fetchAWSEC2Instances(ctx context.Context) ([]*accessgraphv1

// awsInstanceToProtoInstance converts an ec2.Instance to accessgraphv1alpha.AWSInstanceV1
// representation.
func awsInstanceToProtoInstance(instance *ec2.Instance, accountID string) *accessgraphv1alpha.AWSInstanceV1 {
func awsInstanceToProtoInstance(instance *ec2.Instance, region string, accountID string) *accessgraphv1alpha.AWSInstanceV1 {
var tags []*accessgraphv1alpha.AWSTag
for _, tag := range instance.Tags {
tags = append(tags, &accessgraphv1alpha.AWSTag{
Expand All @@ -125,7 +125,7 @@ func awsInstanceToProtoInstance(instance *ec2.Instance, accountID string) *acces
}
return &accessgraphv1alpha.AWSInstanceV1{
InstanceId: aws.ToString(instance.InstanceId),
Region: aws.ToString(instance.Placement.AvailabilityZone),
Region: region,
PublicDnsName: aws.ToString(instance.PublicDnsName),
LaunchKeyName: strPtrToWrapper(instance.KeyName),
IamInstanceProfileArn: instanceProfileMetadata,
Expand Down

0 comments on commit a190ede

Please sign in to comment.