From 38295d478d65ff3bc9932bde379422fc9748ef54 Mon Sep 17 00:00:00 2001 From: Aiden Keating Date: Mon, 10 Aug 2020 15:54:02 +0100 Subject: [PATCH] ensure duplicate azs are never used currently it is possible that duplicate azs in a region are used to attempt to create a subnet group, under two conditions. - aws returns a duplicate set of subnet groups - a legacy subnet exists ensure that duplicate azs are never used in subnet creation by filtering out any duplicates. verification: - run 'make run' - create a redis and postgres instance - ensure both instances are created successfully in aws --- pkg/providers/aws/cluster_network_provider.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/providers/aws/cluster_network_provider.go b/pkg/providers/aws/cluster_network_provider.go index 770efeb9e..37ac9d4be 100644 --- a/pkg/providers/aws/cluster_network_provider.go +++ b/pkg/providers/aws/cluster_network_provider.go @@ -1041,14 +1041,19 @@ func (n *NetworkProvider) reconcileStandaloneVPCSubnets(ctx context.Context, log } // filter the availability zones to only include ones that support the default instance types. + // ensure if any duplicate regions are returned, they are removed. var supportedAzs []*ec2.AvailabilityZone for _, az := range azs.AvailabilityZones { + foundAz := false for _, instanceTypeOffering := range describeInstanceTypeOfferingsOutput.InstanceTypeOfferings { if aws.StringValue(instanceTypeOffering.Location) == aws.StringValue(az.ZoneName) { - supportedAzs = append(supportedAzs, az) - continue + foundAz = true + break } } + if foundAz { + supportedAzs = append(supportedAzs, az) + } } // sort the azs first