Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions upup/pkg/fi/cloudup/awsup/aws_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ func FindRegion(cluster *kops.Cluster) (string, error) {

nodeZones := make(map[string]bool)
for _, subnet := range cluster.Spec.Networking.Subnets {
if subnet.Zone == "" && subnet.ID != "" {
// Subnet ID is provided, so we can skip zone check here.
// The zone will be resolved from AWS later.
continue
}
if len(subnet.Zone) <= 2 {
return "", fmt.Errorf("invalid AWS zone: %q in subnet %q", subnet.Zone, subnet.Name)
}
Expand Down
18 changes: 18 additions & 0 deletions upup/pkg/fi/cloudup/awsup/aws_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ func TestFindRegion(t *testing.T) {
}
}

func TestFindRegion_SubnetIDWithoutZone(t *testing.T) {
c := &kops.Cluster{}
c.Spec.Networking.Subnets = []kops.ClusterSubnetSpec{
{Name: "subnet-1", Zone: "us-east-1a"},
{Name: "subnet-2", ID: "subnet-12345678"}, // No zone, but has ID
}

region, err := FindRegion(c)
if err != nil {
t.Fatalf("unexpected error finding region: %v", err)
}

expected := "us-east-1"
if region != expected {
t.Fatalf("expected region %q, got %q", expected, region)
}
}

func TestEC2TagSpecification(t *testing.T) {
cases := []struct {
Name string
Expand Down
Loading