Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Properly target the region filter. #3225

Merged
merged 8 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion providers/aws/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func NewAwsConnection(id uint32, asset *inventory.Asset, conf *inventory.Config)
c.connectionOptions = asset.Options
if conf.Discover != nil {
c.Filters = parseOptsToFilters(conf.Discover.Filter)
c.RegionLimits = c.Filters.GeneralDiscoveryFilters.Regions
c.RegionLimits = firstNonEmptyRegion(c.Filters.GeneralDiscoveryFilters.Regions, c.Filters.Ec2DiscoveryFilters.Regions)
montera82 marked this conversation as resolved.
Show resolved Hide resolved
}
return c, nil
}
Expand Down Expand Up @@ -288,6 +288,14 @@ func CheckRegion(cfg aws.Config) error {
return nil
}

// firstNonEmptyRegion determines and return the first non-empty region.
func firstNonEmptyRegion(generalRegion, ec2Region []string) []string {
if len(ec2Region) > 0 {
return ec2Region
}
return generalRegion
}

func CheckIam(cfg aws.Config) (*sts.GetCallerIdentityOutput, error) {
ctx := context.Background()
svc := sts.NewFromConfig(cfg)
Expand Down
2 changes: 1 addition & 1 deletion providers/aws/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func parseFlagsToFiltersOpts(m map[string]*llx.Primitive) map[string]string {
if k == "instance-id" {
o[k] = string(v.Value)
}
if strings.Contains(k, ":region") {
if strings.Contains(k, "region") {
montera82 marked this conversation as resolved.
Show resolved Hide resolved
o[k] = string(v.Value)
}
}
Expand Down
Loading