From ab47eb11b3d5e78fa5da09771e7bf14ff72aff75 Mon Sep 17 00:00:00 2001 From: Erik Kristensen Date: Mon, 9 Dec 2024 17:27:09 -0700 Subject: [PATCH] fix(gamelift): skip unsupported regions --- resources/gamelift-build.go | 12 +++++++++++- resources/gamelift-fleet.go | 12 +++++++++++- resources/gamelift-mm-config.go | 12 +++++++++++- resources/gamelift-mm-rule.go | 12 +++++++++++- resources/gamelift-queue.go | 12 +++++++++++- resources/gamelift.go | 23 +++++++++++++++++++++++ 6 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 resources/gamelift.go diff --git a/resources/gamelift-build.go b/resources/gamelift-build.go index 57808692..2e69b3ba 100644 --- a/resources/gamelift-build.go +++ b/resources/gamelift-build.go @@ -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{} diff --git a/resources/gamelift-fleet.go b/resources/gamelift-fleet.go index b4c52f18..90b3507f 100644 --- a/resources/gamelift-fleet.go +++ b/resources/gamelift-fleet.go @@ -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{} diff --git a/resources/gamelift-mm-config.go b/resources/gamelift-mm-config.go index 797f2fcf..9ed9b66c 100644 --- a/resources/gamelift-mm-config.go +++ b/resources/gamelift-mm-config.go @@ -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{} diff --git a/resources/gamelift-mm-rule.go b/resources/gamelift-mm-rule.go index 81fabee0..e2cf5787 100644 --- a/resources/gamelift-mm-rule.go +++ b/resources/gamelift-mm-rule.go @@ -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{} diff --git a/resources/gamelift-queue.go b/resources/gamelift-queue.go index 00f39188..74f82bb7 100644 --- a/resources/gamelift-queue.go +++ b/resources/gamelift-queue.go @@ -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{} diff --git a/resources/gamelift.go b/resources/gamelift.go new file mode 100644 index 00000000..8503c331 --- /dev/null +++ b/resources/gamelift.go @@ -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) +}