Skip to content

Commit

Permalink
Restore for loop in aws cloud prepare for owned filters
Browse files Browse the repository at this point in the history
While retrieving vpc the owned filters should be tried
one after the other than together.

Signed-off-by: Aswin Suryanarayanan <[email protected]>
  • Loading branch information
aswinsuryan authored and Jaanki committed Nov 13, 2024
1 parent 1d81038 commit ee90732
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pkg/aws/vpcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,20 @@ func (ac *awsCloud) getVpcID() (string, error) {
ownedFilters := ac.filterByCurrentCluster()
vpcName := ac.withAWSInfo("{infraID}-vpc")

filters := []types.Filter{
ac.filterByName(vpcName),
}
filters = append(filters, ownedFilters...)
for i := range ownedFilters {
filters := []types.Filter{
ac.filterByName(vpcName),
ownedFilters[i],
}

result, err = ac.client.DescribeVpcs(context.TODO(), &ec2.DescribeVpcsInput{Filters: filters})
if err != nil {
return "", errors.Wrap(err, "error describing AWS VPCs")
result, err = ac.client.DescribeVpcs(context.TODO(), &ec2.DescribeVpcsInput{Filters: filters})
if err != nil {
return "", errors.Wrap(err, "error describing AWS VPCs")
}

if len(result.Vpcs) != 0 {
break
}
}

if len(result.Vpcs) == 0 {
Expand Down

0 comments on commit ee90732

Please sign in to comment.