diff --git a/pkg/asset/installconfig/aws/permissions.go b/pkg/asset/installconfig/aws/permissions.go index 42734e1e34c..58f6a812d67 100644 --- a/pkg/asset/installconfig/aws/permissions.go +++ b/pkg/asset/installconfig/aws/permissions.go @@ -739,8 +739,9 @@ func includesAssumeRole(installConfig *types.InstallConfig) bool { } func includesWavelengthZones(installConfig *types.InstallConfig) bool { - // Examples of WL zones: us-east-1-wl1-atl-wlz-1, eu-west-2-wl1-lon-wlz-1, eu-west-2-wl2-man-wlz1 ... - isWLZoneRegex := regexp.MustCompile(`wl\d\-.*$`) + // Examples of WL zones: us-east-1-wl1-atl-wlz-1, eu-west-2-wl1-lon-wlz-1, eu-west-2-wl2-man-wlz-1, etc + // https://docs.aws.amazon.com/wavelength/latest/developerguide/available-wavelength-zones.html + isWLZoneRegex := regexp.MustCompile(`-wlz.*$`) for _, mpool := range installConfig.Compute { if mpool.Name != types.MachinePoolEdgeRoleName || mpool.Platform.AWS == nil { diff --git a/pkg/asset/installconfig/aws/permissions_test.go b/pkg/asset/installconfig/aws/permissions_test.go index 68f5a2fa096..6a5baaab011 100644 --- a/pkg/asset/installconfig/aws/permissions_test.go +++ b/pkg/asset/installconfig/aws/permissions_test.go @@ -878,17 +878,33 @@ func TestIncludesAssumeRole(t *testing.T) { func TestIncludesWavelengthZones(t *testing.T) { t.Run("Should be true when edge compute specified with WL zones", func(t *testing.T) { - ic := validBYOSubnetsInstallConfig() - ic.Compute = append(ic.Compute, types.MachinePool{ - Name: "edge", - Platform: types.MachinePoolPlatform{ - AWS: &aws.MachinePool{ - Zones: []string{"us-west-2-pdx-1a", "us-west-2-wl1-sea-wlz-1"}, + t.Run("with common wavelength zone format", func(t *testing.T) { + ic := validBYOSubnetsInstallConfig() + ic.Compute = append(ic.Compute, types.MachinePool{ + Name: "edge", + Platform: types.MachinePoolPlatform{ + AWS: &aws.MachinePool{ + Zones: []string{"us-west-2-pdx-1a", "us-west-2-wl1-sea-wlz-1"}, + }, }, - }, + }) + requiredPerms := RequiredPermissionGroups(ic) + assert.Contains(t, requiredPerms, PermissionCarrierGateway) + }) + // OCPBUGS-77355: for example, us-east-1-foe-wlz-1a + t.Run("with irregular wavelength zone format", func(t *testing.T) { + ic := validBYOSubnetsInstallConfig() + ic.Compute = append(ic.Compute, types.MachinePool{ + Name: "edge", + Platform: types.MachinePoolPlatform{ + AWS: &aws.MachinePool{ + Zones: []string{"us-west-2-pdx-1a", "us-east-1-foe-wlz-1a", "eu-west-3-cmn-wlz-1a"}, + }, + }, + }) + requiredPerms := RequiredPermissionGroups(ic) + assert.Contains(t, requiredPerms, PermissionCarrierGateway) }) - requiredPerms := RequiredPermissionGroups(ic) - assert.Contains(t, requiredPerms, PermissionCarrierGateway) }) t.Run("Should be false when", func(t *testing.T) { t.Run("edge compute specified without WL zones", func(t *testing.T) {