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

Bug 1945467: aws: allow use of unknown regions in known partitions #4807

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 3 additions & 13 deletions pkg/asset/installconfig/aws/validation.go
Expand Up @@ -12,6 +12,7 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation/field"

"github.com/openshift/installer/pkg/rhcos"
"github.com/openshift/installer/pkg/types"
awstypes "github.com/openshift/installer/pkg/types/aws"
)
Expand Down Expand Up @@ -55,7 +56,7 @@ func Validate(ctx context.Context, meta *Metadata, config *types.InstallConfig)
func validatePlatform(ctx context.Context, meta *Metadata, fldPath *field.Path, platform *awstypes.Platform, networking *types.Networking, publish types.PublishingStrategy) field.ErrorList {
allErrs := field.ErrorList{}

if !isAWSSDKRegion(platform.Region) && platform.AMIID == "" {
if !sets.NewString(rhcos.AMIRegions...).Has(platform.Region) && platform.AMIID == "" {
allErrs = append(allErrs, field.Required(fldPath.Child("amiID"), "AMI must be provided"))
}

Expand Down Expand Up @@ -211,7 +212,7 @@ func validateDuplicateSubnetZones(fldPath *field.Path, subnets map[string]Subnet
}

func validateServiceEndpoints(fldPath *field.Path, region string, services []awstypes.ServiceEndpoint) error {
if isAWSSDKRegion(region) {
if _, partitionFound := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), region); partitionFound {
return nil
}

Expand All @@ -226,17 +227,6 @@ func validateServiceEndpoints(fldPath *field.Path, region string, services []aws
return utilerrors.NewAggregate(errs)
}

func isAWSSDKRegion(region string) bool {
for _, partition := range endpoints.DefaultPartitions() {
for _, partitionRegion := range partition.Regions() {
if region == partitionRegion.ID() {
return true
}
}
}
return false
}

var requiredServices = []string{
"ec2",
"elasticloadbalancing",
Expand Down