diff --git a/resources/iottwinmaker-component-type.go b/resources/iottwinmaker-component-type.go index 31cab4b9..17ba1a45 100644 --- a/resources/iottwinmaker-component-type.go +++ b/resources/iottwinmaker-component-type.go @@ -26,13 +26,19 @@ func init() { }) } -type IoTTwinMakerComponentTypeLister struct{} +type IoTTwinMakerComponentTypeLister struct { + IoTTwinMaker +} func (l *IoTTwinMakerComponentTypeLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) { opts := o.(*nuke.ListerOpts) + resources := make([]resource.Resource, 0) + + if !l.IsSupportedRegion(opts.Region.Name) { + return resources, nil + } svc := iottwinmaker.New(opts.Session) - resources := make([]resource.Resource, 0) // Require to have workspaces identifiers to query components workspaceListResponse, err := ListWorkspacesComponentType(svc) diff --git a/resources/iottwinmaker-entity.go b/resources/iottwinmaker-entity.go index a4d4bb25..f56085b3 100644 --- a/resources/iottwinmaker-entity.go +++ b/resources/iottwinmaker-entity.go @@ -24,13 +24,19 @@ func init() { }) } -type IoTTwinMakerEntityLister struct{} +type IoTTwinMakerEntityLister struct { + IoTTwinMaker +} func (l *IoTTwinMakerEntityLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) { opts := o.(*nuke.ListerOpts) + resources := make([]resource.Resource, 0) + + if !l.IsSupportedRegion(opts.Region.Name) { + return resources, nil + } svc := iottwinmaker.New(opts.Session) - resources := make([]resource.Resource, 0) // Require to have workspaces identifiers to query entities workspaceListResponse, err := ListWorkspacesEntities(svc) diff --git a/resources/iottwinmaker-scene.go b/resources/iottwinmaker-scene.go index b4690ef5..20fbce91 100644 --- a/resources/iottwinmaker-scene.go +++ b/resources/iottwinmaker-scene.go @@ -24,13 +24,19 @@ func init() { }) } -type IoTTwinMakerSceneLister struct{} +type IoTTwinMakerSceneLister struct { + IoTTwinMaker +} func (l *IoTTwinMakerSceneLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) { opts := o.(*nuke.ListerOpts) + resources := make([]resource.Resource, 0) + + if !l.IsSupportedRegion(opts.Region.Name) { + return resources, nil + } svc := iottwinmaker.New(opts.Session) - resources := make([]resource.Resource, 0) // Require to have workspaces identifiers to query scenes workspaceListResponse, err := ListWorkspacesScene(svc) diff --git a/resources/iottwinmaker-sync-job.go b/resources/iottwinmaker-sync-job.go index 5b22fe8c..ab3c417c 100644 --- a/resources/iottwinmaker-sync-job.go +++ b/resources/iottwinmaker-sync-job.go @@ -24,13 +24,19 @@ func init() { }) } -type IoTTwinMakerSyncJobLister struct{} +type IoTTwinMakerSyncJobLister struct { + IoTTwinMaker +} func (l *IoTTwinMakerSyncJobLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) { opts := o.(*nuke.ListerOpts) + resources := make([]resource.Resource, 0) + + if !l.IsSupportedRegion(opts.Region.Name) { + return resources, nil + } svc := iottwinmaker.New(opts.Session) - resources := make([]resource.Resource, 0) // Require to have workspaces identifiers to query sync jobs workspaceListResponse, err := ListWorkspacesSyncJob(svc) diff --git a/resources/iottwinmaker-workspace.go b/resources/iottwinmaker-workspace.go index c7572e06..5e542c52 100644 --- a/resources/iottwinmaker-workspace.go +++ b/resources/iottwinmaker-workspace.go @@ -30,13 +30,19 @@ func init() { }) } -type IoTTwinMakerWorkspaceLister struct{} +type IoTTwinMakerWorkspaceLister struct { + IoTTwinMaker +} func (l *IoTTwinMakerWorkspaceLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) { opts := o.(*nuke.ListerOpts) + resources := make([]resource.Resource, 0) + + if !l.IsSupportedRegion(opts.Region.Name) { + return resources, nil + } svc := iottwinmaker.New(opts.Session) - resources := make([]resource.Resource, 0) params := &iottwinmaker.ListWorkspacesInput{ MaxResults: aws.Int64(25), diff --git a/resources/iottwinmaker.go b/resources/iottwinmaker.go new file mode 100644 index 00000000..03fccb64 --- /dev/null +++ b/resources/iottwinmaker.go @@ -0,0 +1,27 @@ +package resources + +import "slices" + +type IoTTwinMaker struct{} + +func (i *IoTTwinMaker) IsSupportedRegion(region string) bool { + // ref: https://docs.aws.amazon.com/general/latest/gr/iot-twinmaker.html + supportedRegions := []string{ + "us-east-1", + "us-west-2", + "ap-south-1", + "ap-northeast-2", + "ap-southeast-1", + "ap-southeast-2", + "ap-northeast-1", + "eu-central-1", + "eu-west-1", + "us-gov-west-1", + } + + if slices.Contains(supportedRegions, region) { + return true + } + + return false +}