Skip to content

Commit

Permalink
Merge pull request #452 from ekristen/fix-gamelift-supported-regions
Browse files Browse the repository at this point in the history
fix(gamelift): skip unsupported regions
  • Loading branch information
ekristen authored Dec 12, 2024
2 parents e2ccfbc + ab47eb1 commit 96c5b90
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 5 deletions.
12 changes: 11 additions & 1 deletion resources/gamelift-build.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,22 @@ func init() {
})
}

type GameLiftBuildLister struct{}
type GameLiftBuildLister struct {
GameLift
}

func (l *GameLiftBuildLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
opts := o.(*nuke.ListerOpts)
var resources []resource.Resource

if !l.IsSupportedRegion(opts.Region.Name) {
opts.Logger.
WithField("resource", GameLiftBuildResource).
WithField("region", opts.Region.Name).
Debug("region not supported")
return resources, nil
}

svc := gamelift.New(opts.Session)

params := &gamelift.ListBuildsInput{}
Expand Down
12 changes: 11 additions & 1 deletion resources/gamelift-fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,22 @@ func init() {
})
}

type GameLiftFleetLister struct{}
type GameLiftFleetLister struct {
GameLift
}

func (l *GameLiftFleetLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
opts := o.(*nuke.ListerOpts)
var resources []resource.Resource

if !l.IsSupportedRegion(opts.Region.Name) {
opts.Logger.
WithField("resource", GameLiftFleetResource).
WithField("region", opts.Region.Name).
Debug("region not supported")
return resources, nil
}

svc := gamelift.New(opts.Session)

params := &gamelift.ListFleetsInput{}
Expand Down
12 changes: 11 additions & 1 deletion resources/gamelift-mm-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,22 @@ func init() {
})
}

type GameLiftMatchmakingConfigurationLister struct{}
type GameLiftMatchmakingConfigurationLister struct {
GameLift
}

func (l *GameLiftMatchmakingConfigurationLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
opts := o.(*nuke.ListerOpts)
var resources []resource.Resource

if !l.IsSupportedRegion(opts.Region.Name) {
opts.Logger.
WithField("resource", GameLiftMatchmakingConfigurationResource).
WithField("region", opts.Region.Name).
Debug("region not supported")
return resources, nil
}

svc := gamelift.New(opts.Session)

params := &gamelift.DescribeMatchmakingConfigurationsInput{}
Expand Down
12 changes: 11 additions & 1 deletion resources/gamelift-mm-rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,22 @@ func init() {
})
}

type GameLiftMatchmakingRuleSetLister struct{}
type GameLiftMatchmakingRuleSetLister struct {
GameLift
}

func (l *GameLiftMatchmakingRuleSetLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
opts := o.(*nuke.ListerOpts)
var resources []resource.Resource

if !l.IsSupportedRegion(opts.Region.Name) {
opts.Logger.
WithField("resource", GameLiftMatchmakingRuleSetResource).
WithField("region", opts.Region.Name).
Debug("region not supported")
return resources, nil
}

svc := gamelift.New(opts.Session)

params := &gamelift.DescribeMatchmakingRuleSetsInput{}
Expand Down
12 changes: 11 additions & 1 deletion resources/gamelift-queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,22 @@ func init() {
})
}

type GameLiftQueueLister struct{}
type GameLiftQueueLister struct {
GameLift
}

func (l *GameLiftQueueLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) {
opts := o.(*nuke.ListerOpts)
var resources []resource.Resource

if !l.IsSupportedRegion(opts.Region.Name) {
opts.Logger.
WithField("resource", GameLiftQueueResource).
WithField("region", opts.Region.Name).
Debug("region not supported")
return resources, nil
}

svc := gamelift.New(opts.Session)

params := &gamelift.DescribeGameSessionQueuesInput{}
Expand Down
23 changes: 23 additions & 0 deletions resources/gamelift.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package resources

import "slices"

type GameLift struct{}

func (g *GameLift) IsSupportedRegion(region string) bool {
// ref: https://docs.aws.amazon.com/gamelift/latest/developerguide/gamelift-regions.html
// there are fewer unsupported, so doing the inverse
// unsupported are regions that only support "Remote location for multi-location fleets"
// note: we do not currently filter down to the local zone
unsupportedRegions := []string{
"af-south-1",
"ap-east-1",
"ap-northeast-3",
"eu-north-1",
"eu-south-1",
"eu-west-3",
"me-south-1",
}

return !slices.Contains(unsupportedRegions, region)
}

0 comments on commit 96c5b90

Please sign in to comment.