Skip to content

Commit

Permalink
Filter only kops ec2 resource with type ec2.ResourceTypeSubnet (#1752)
Browse files Browse the repository at this point in the history
Ensure that only resource with type ec2.ResourceTypeSubnet are processed by ListSubnets 


When subnets carries AssociatedElasticIp or AssociatedNatgateway tag,
ListSubnets function doesn't always return resources with
ec2.ResourceTypeSubnet type

These resources doesn’t have Obj property causing type conversion from
nil into *ec2.Subnet to panic

Issue #1410
  • Loading branch information
rimaulana authored May 12, 2020
1 parent 2742c72 commit 9ba4485
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/kops/kops.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func (k *Wrapper) UseVPC(provider api.ClusterProvider, spec *api.ClusterConfig)
}

for _, subnet := range allSubnets {
if subnet.Type != ec2.ResourceTypeSubnet {
continue
}
subnet := subnet.Obj.(*ec2.Subnet)
for _, tag := range subnet.Tags {
if k.isOwned(tag) {
Expand Down

0 comments on commit 9ba4485

Please sign in to comment.